Two Guys Arguing

Pro Tips: Run Multiple Jenkins CI Servers on a Single Machine

Posted in software development, software testing by benjaminplee on 07.24.11

Jenkins (or Hudson if you work for Oracle) is a great, simple and steady continuous integration and build server.  One of its greatest features is that despite being packaged as a standard .war ready to be dropped into your JEE web container of choice … it also contains an embedded web container that makes the .war everything you need in most situations.  Simply run

java -jar jenkins.war

and up starts Jenkins on port 8080 in all of its glory.  All of Jenkins’ configuration files, plugins, and working directories go under <USER_HOME>/.jenkins by default.  Perfect.

Except if you want to run multiple instances on the same machine.  We are going to get a config folder collision.  It turns out this is a piece of cake, but the docs are hard to find.  Jenkins will use a JENKINS_HOME path environement variable for its configuration files if one is set so a simple change means we can run Jenkins out of any directory we desire:

java -DJENKINS_HOME=/path/to/configs -jar jenkins.war

What about the port you say?  Winston, the embedded web container used, has a simple property for this too:

java -DJENKINS_HOME=/path/to/configs -jar jenkins.war --httpPort=9090

11 Responses

Subscribe to comments with RSS.

  1. Brian Smith (@brianthesmith) said, on 08.11.11 at 8:52 pm

    Is the config folder location also necessary when running as a war from inside a full tomcat? It doesn’t just blow the config folder out into tomcat somewhere?

    • sudeepsthoughts said, on 12.06.16 at 10:21 am

      Not required. I provided below in the

      CATALINA_OPTS=”-Xmx768m -XX:MaxPermSize=256m”
      export CATALINA_OPTS
      export JAVA_HOME=/opt/java1.8
      export HUDSON_HOME=/opt/Hudson

      Once tomcat is started hudson will run in /opt/Hudson as home directory and all configs there. Hope this helps.

  2. benjaminplee said, on 08.11.11 at 9:06 pm

    Honestly, I don’t know. I have always run Hudson/Jenkins directly using the embedded web application server. Given how easy it is to spin up slave nodes via JNLP, we didn’t end up going this direction.

    • Davis.xie said, on 01.21.15 at 1:21 am

      Hello Benjaminplee,
      Can you please explain a lit more detailed step and what happens? I copy and paste the commands, which works, but would like to understand it. If you can explain on your commands that would be great.
      The goal that I would like to achieve: two instances of Jenkins on one machine, one as Master and one as slave. Does this commands installs two instances of Jenkins ?

    • Why said, on 01.21.15 at 2:31 am

      I am new totally new to *inux O. If you know, Can you explain/(or share the link) why there are two folder after installing jenkins. (jar -xvf sample.war jenkins.war).

  3. Chris said, on 01.10.14 at 12:22 am

    Really helpful, I did exactly as you said and worked. tks!!

  4. Pedro de Almeida said, on 03.12.14 at 12:40 pm

    Thank you, this tip was really helpful.

  5. Niddhi said, on 05.01.14 at 1:07 am

    I am new to Jenkins and i need to create 2 instances of Jenkins to run separate projects on each.
    I need 2 diff url to access Jenkins instances.

    Please let me know how to do that.


  6. Steve said, on 02.24.16 at 12:08 pm


    Could you please provide the steps how to do it?

    I already have a Jenkins installed on a windows box running on port 8080. Now I need to install a new standalone Jenkins for a different project on the same box running on a different port . How can it be done without conflicts occurring between the two projects.


    • Christiano Moreira said, on 02.25.16 at 5:49 pm

      easy do as it says above
      java -DJENKINS_HOME=/path/to/configs -jar jenkins.war –httpPort=9090

      Check the documentation if you need more help

  7. Bia said, on 08.20.18 at 5:27 am


    I need to run two Jenkins instances under Tomcat. The reason is I need to have the latest Jenkins version, but also an older version for older project which are not compatible with newest Jenkins.
    Usually I just place the .war file under [Tomcat_root]\webapps and have the JENKINS_HOME environment variable set as desired.
    This is conflicting if I deploy a second jenkins_old.war file.
    >> Unable to create the home directory ‘C:\Programs\Jenkins;C:\Programs\Jenkins_old’. This is most likely a permission problem.
    As seen above I tried to set two different paths for two Jenkins instances. Does not work.
    Note: Running under Windows Server 2012

    Can you give a piece of advice?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s