Extremely Serious

Category: Jenkins

Installing Jenkins in Ubuntu


  • Java 8 +

Installing Jenkins

  1. Install the jenkins key:
    wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  2. Register the jenkins source:
    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  3. Add the universe repository:
    sudo add-apt-repository universe
  4. Update the repository:
    sudo apt-get update
  5. Install jenkins:
    sudo apt-get install jenkins -y

Preparing Jenkins

  1. Access jenkins:
  2. Use the password found from the following file for Administrator Password:
    sudo less /var/lib/jenkins/secrets/initialAdminPassword
  3. In Getting Started page select:
    Install suggested plugins
  4. Create the first admin user.
  5. Provide the Jenkins URL in the Instance Configuration.
  6. Click the Start using Jenkins button.

Changing Jenkins Port

  1. Open the file jenkins.xml from the location where Jenkins was installed (e.g. C:\Program Files (x86)\Jenkins).
  2. Search for httpPort and updated it with whatever you wanted it to be (e.g. 9080) as long as it doesn't introduce any conflicts.

    Example update to 9080

    <arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=9080 --webroot="%BASE%\war"</arguments>

Triggering builds remotely with Jenkins using HTTP Request plugin

Use Cases

Lower Jenkins (e.g. v1.x) but requires later Jenkins (e.g. v2.x) functionality (e.g. using git plugin which has some transitive dependencies which requires v2.x).

For some reason , we just wanted a Jenkins server to delegate a task to another Jenkins server.

You've created a script (i.e. python, ruby, groovy, etc) that will trigger a Jenkins task via HTTP protocol. This is not part of this document but the Backend Jenkins Server section is applicable.

Backend Jenkins Server

This is the server that will perform the task.

Setting-up a role that can do remote build

  1. Click Jenkins -> Manage Jenkins -> Manage and Assign Roles entry and select Manage Roles.
  2. In the Global roles, add a new role (e.g. remote_triggers) that is allowed to trigger a task remotely.
  3. Once added enable the following:
Overall Read
Job Build
Job Read
Job Workspace

Example 1: Sample role configuration

If we have remote_triggers as the new role, we have the following:

Assigning a role to a user

  1. Click Jenkins -> Manage Jenkins -> Manage and Assign Roles entry and select Assign Role.
  2. In the Global roles, add a known Jenkins user.
  3. Once added assign the role.

Example 2: Assign a role following Example 1.

If the known user is GwDevOpsDev, we have the following:

Setting-up the Build Triggers

  1. On the Build Triggers section, select the Trigger builds remotely (e.g., from scripts).
  2. Provide an Authentication Token.

Note: You can use https://www.guidgenerator.com/ just remove the hyphen for this.

This will enable you to trigger the job remotely via HTTP Post using one of the following:

Without Build Parameters


With Build Parameters


Example 3: Address to call a task remotely.

If we have the following:

JENKINS_URL = http://d-51306g2.fmg.net:9080
ITEM_NAME=Statement Date Update to Saturday

The URL to call this job remotely with build parameters must be:


User Facing Jenkins Server

This is the Jenkins server that is normally use by the user to invoke tasks but the task is actually being done by a another Jenkins server.


  • HTTP Request Plugin

Setting-up Credential to be used with the HTTP request.

  1. Click Jenkins -> Credentials entry.
  2. Click the global store seen as follows:
  3. Click Add Credentials.
  4. Set the Kind field to Username with Password.
  5. Set the Scope field to Global if not yet set.
  6. Set the Username field to the user that can to remote triggering configured on the backend Jenkins server (e.g. GwDevOpsDev from Example 2).
  7. Set the Password field to a valid password.
  8. Set the ID field to something unique.
    Note: You can use https://www.guidgenerator.com/  for this.
  9. Click the OK button.

Setting-up a New Item to Delegate Task to Backend Jenkins Server

  1. Click New Item.
  2. Provide an Item name.
  3. Select Freestyle project.
  4. Click the OK button.
  5. Click Add build step-> HTTP Request entry.
  6. Fill-in the URL with the one configured in the backend Jenkins server (e.g. http://d-51306g2.fmg.net:9080/job/Statement%20Date%20Update%20to%20Saturday/buildWithParameters?token=49dcf6a2164147b1871de70b40afef6f from Example 3)
  7. Select POST for the HTTP mode.
  8. Click the Advanced… button.
  9. In the Authenticate field select the set up from Setting-up Credential to be used with the HTTP request section earlier.
  10. Click the Save button.
  11. Now every time you click Build now it will complete immediately since the actual build will be done on the Backend Jenkins Server.