Starting and Accessing Jenkins

Skip to end of metadata
Go to start of metadata

Starting Jenkins

The easiest way to execute Jenkins is through the built in Winstone servlet container. You can execute Jenkins like this:

$ java -jar jenkins.war

Of course, you probably want to send the output of Jenkins to a log file, and if you're on Unix, you probably want to use nohup:

$ nohup java -jar jenkins.war > $LOGFILE 2>&1

Accessing Jenkins

To see Jenkins, simply bring up a web browser and go to URL http://myServer:8080 where myServer is the name of the system running Jenkins.

Top of page

Command Line Parameters

Jenkins normally starts up using port 8080. However, if you have other web services starting up you might find that this port is already taken. You can specify a different port by using --httpPort=$HTTP_PORT where $HTTP_PORT is the port you want Jenkins to run on. Other command line parameters include:

Command Line Parameter Description
--httpPort=$HTTP_PORT Runs Jenkins listener on port $HTTP_PORT using standard http protocol. The default is port 8080. To disable (because you're using https), use port -1.
--httpListenAddress=$HTTP_HOST Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces.
For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1
--httpsPort=$HTTP_PORT Uses HTTPS protocol on port $HTTP_PORT
--httpsListenAddress=$HTTPS_HOST Binds Jenkins to listen for HTTPS requests on the IP address represented by $HTTPS_HOST.
--prefix=$PREFIX
Runs Jenkins to include the $PREFIX at the end of the URL.
For example, to make Jenkins accessible at http://myServer:8080/jenkins, set --prefix=/jenkins
--ajp13Port=$AJP_PORT Runs Jenkins listener on port $AJP_PORT using standard AJP13 protocol. The default is port 8009. To disable (because you're using https), use port -1.
--ajp13ListenAddress=$AJP_HOST Binds Jenkins to the IP address represented by $AJP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces.
--argumentsRealm.passwd.$ADMIN_USER Sets the password for user $ADMIN_USER. If Jenkins security is turned on, you must log in as the $ADMIN_USER in order to configure Jenkins or a Jenkins project. NOTE: You must also specify that this user has an admin role. (See next argument below).
--argumentsRealm.roles.$ADMIN_USER=admin Sets that $ADMIN_USER is an administrative user and can configure Jenkins if Jenkins' security is turned on. See Securing Jenkins for more information.
-Xdebug -Xrunjdwp:transport=dt_socket,address=$DEBUG_PORT,server=y,suspend=n Sets debugging on and you can access debug on $DEBUG_PORT.
-logfile=$LOG_PATH/winstone_`date +"%Y%m-%d_%H-%M"`.log Logging to desired file
-XX:PermSize=512M -XX:MaxPermSize=2048M -Xmn128M -Xms1024M -Xmx2048M referring to these options for Oracle Java

Jenkins passes all (or just leading parameters until the first Jenkins-specific parameter?) command line parameters to the Winstone servlet container, so you can get more information by looking at the Winstone Command Line Parameter Reference

Be Careful with Command Line Parameters
Jenkins ignores command line parameters it doesn't understand instead of producing an error. Be careful when using command line parameters and make sure you have the correct spelling. For example, the parameter needed for defining the Jenkins administrative user is --argumentsRealm and not --argumentRealm.

A very simple init script

The following script is for Ubuntu based systems. The RedHat Jenkins distribution contains a startup script. 
#!/bin/sh

DESC="Jenkins CI Server"
NAME=jenkins
PIDFILE=/var/run/$NAME.pid
RUN_AS=jenkins
COMMAND=/usr/bin/java -- -jar /home/jenkins/jenkins.war

d_start() {
	start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND
}

d_stop() {
	start-stop-daemon --stop --quiet --pidfile $PIDFILE
	if [ -e $PIDFILE ]
		then rm $PIDFILE
	fi
}

case $1 in
	start)
	echo -n "Starting $DESC: $NAME"
	d_start
	echo "."
	;;
	stop)
	echo -n "Stopping $DESC: $NAME"
	d_stop
	echo "."
	;;
	restart)
	echo -n "Restarting $DESC: $NAME"
	d_stop
	sleep 1
	d_start
	echo "."
	;;
	*)
	echo "usage: $NAME {start|stop|restart}"
	exit 1
	;;
esac

exit 0


Using HTTPS with an existing certificate

If you're setting up Jenkins using the built-in Winstone server and want to use an existing certificate for HTTPS:

--httpPort=-1 --httpsPort=443 --httpsKeyStore=path/to/keystore --httpsKeyStorePassword=keystorePassword

The keystore should be in JKS format (as created by the JDK 'keytool') and the keystore and target key must have the same password. (Placing the keystore arguments after Jenkins-specific parameters does not seem to work; either they are not forwarded to Winstone or Winstone ignores them coming after unknown parameters. So, make sure they are adjacent to the working --httpsPort argument.)

If your keystore contains multiple certificates (e.g. you are using CA signed certificate) Jenkins might end-up using a incorrect one. In this case you can convert the keystore to PEM and use following command line options:

--httpPort=-1 --httpsPort=443 --httpsCertificate=path/to/cert --httpsPrivateKey=path/to/privatekey

Top of page

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Nov 13, 2011

    kesten broughton says:

    The >java -jar jenkins.war works fine in my ubuntu terminal.  It say...

    The >java -jar jenkins.war works fine in my ubuntu terminal.  It says it's running.

    But pointing my browser to se it?  I know the port it's on because the terminal output tells me.

    But what is my server name?  I thought using the .war i don't need a server like apache.

    [Winstone 2011/11/12 21:10:51] - Container startup failed
    java.io.IOException: Failed to start a listener: winstone.HttpListener

    errors.......

    Caused by: java.net.BindException: Address already in use

    so i guess the question is, how to find an open port?

    .... ok, so it looks like if you suggest port 0, computer will search for an open one.

    so now i use

    java -jar jenkins.war --httpPort=0

    winstone starts running... yay!   But eventually there is this error:

    INFO: Accepted connection #1 from /127.0.0.1:51728
    Nov 12, 2011 9:35:51 PM hudson.TcpSlaveAgentListener$ConnectionHandler run
    WARNING: Connection #1 failed
    java.io.EOFException

    and i'm still not clear on what should go in the address bar when using the winstone servlet

    kesten

    1. Nov 13, 2011

      kesten broughton says:

      SOLVED The failed connection was likely due to poor internet connectivity. ...

      SOLVED

      The failed connection was likely due to poor internet connectivity. 

      I was able to get the Jenkins dashboard in my browser by pointing it to address 127.0.0.1:8080

      following a tutorial. http://equis.cs.queensu.ca/wiki/index.php/Running_Web_Applications_in_Eclipse

  2. Jan 31, 2012

    Joel Beaudoin says:

    Is there a switch that can be passed to Jenkins on startup that will disable ema...

    Is there a switch that can be passed to Jenkins on startup that will disable email ... or a configuration setting?

    1. Feb 08, 2012

      Joel Beaudoin says:

      Found an alternative. I used the Configuration Slicing Plugin. This is either in...

      Found an alternative. I used the Configuration Slicing Plugin. This is either installed by default or I had already installed it, because it was available as an option from my Manage Jenkins page. I simply used the E-mail Notification slicer and cleared out the settings for all of my jobs, saving things (screen grab) for a later restore.

      I thought I had seen an option for starting Hudson/Jenkins, via the default Winstone container, that toggled email on/off. After doing a bit more searching, I suspect that it was a tomcat-hosted Hudson/Jenkins that I had been using with --disable-email-something-or-other.

  3. Aug 06, 2012

    Steve Meier says:

    Hello, I have just started with Jenkins and it is great - if it starts. I have ...

    Hello,

    I have just started with Jenkins and it is great - if it starts. I have a very big problem and cannot find any information on this page or in Google on how to solve it. I downloaded and installed the Windows package latest version 1.457 and I have installed it as a Windows Service for use with the shipped Winstone servlet container. My system is a Windows XP SP3 system with .Net 3.5, Java in version 1.7, and I am admin on the system.

    After installation the Jenkins service is correctly started and it works. But if I stop the service, a restart is most of the times impossible, but in very rare cases it works. In the failure cases all I get is the error message that the service Jenkins was started on Local Computer and then halted. The event log does not give any hint, even the log files in the Jenkins program folder do not inform me. How can I enable the Java logging to find the reason for the startup problem? The examples on the page refer to logging of disk space, but sorry, I am not a Java programmer I do not know on how to enable other loggings (I want to use Jenkins for queuing of time-consuming report jobs). Can anybody help me saying which switch I have to set to enable this logging?

    And what is very weird: If I start the service with "java -jar jenkins.war" all the configuration that I did, when I started it as a service, is gone - like a totally new installation. And if for some reason I get the Windows service started, the original configuration with all jobs is back. So there must be a difference in the service and in the manual start as a java program. Would it be possible to specify the configuration that I configured while it was started as a service, with "java -jar jenkins.war"?

    Sorry, maybe it is all trivial, because I seem to be the only one with these questions, but however I do not find it myself and would appreciate any support.

    Steve

  4. Jun 25, 2013

    Ostap Bender says:

    When I run $ java -jar jenkins.war on Windows XP it creates .jenkins/work...

    When I run

    $ java -jar jenkins.war on Windows XP

    it creates .jenkins/workspace under user.home see below:

       Running from: C:\Jenkins\jenkins.war

       webroot: $user.home/.jenkins

    Is it possible assign to another directory for instance: C:\web\.jenkins ?

    Could you suggest me please?

    1. Oct 30

      Markus Kemp says:

      Hi. In case you haven't found a solution yet, here's what I think should work (a...

      Hi. In case you haven't found a solution yet, here's what I think should work (at least it seems to work with version 1.537 on Windows 7). Set your JENKINS_HOME environment variable to the desired path (i.e. C:\web\.jenkins, in your case). Then restart your jenkins.war (be sure to do it in the same Shell window in which you've set the JENKINS_HOME environment variable).

      If you're running Jenkins as a Windows service, also edit jenkins.xml (located in the Jenkins install directory) and comment out the line <env name="JENKINS_HOME" value="%BASE%"/>, or else Jenkins will ignore your JENKINS_HOME environment variable. Hope this helps.

  5. Dec 18

    David Aldrich says:

    May I suggest documenting the --sessionTimeout parameter (introduced in 1.52...

    May I suggest documenting the --sessionTimeout parameter (introduced in 1.528) here?