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

8 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?

  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

    Hey,
    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.

    Thanks,
    Niddhi

    • Vladislav Židek said, on 09.11.14 at 8:47 am

      You can run it twice, with different parameters.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.