Feb 13

Continuous Delivery Part 2: Implementing a Deployment Pipeline with Jenkins

In this post we will build a very basic deployment pipeline using the Jenkins Continuous Integration Server and the Build Pipeline Jenkins plugin.

For an overview on deployment pipelines see my previous post Building deployment pipelines.

This basic pipeline will consist of a number of jobs:

  1. Build the artifact
  2. Acceptance testing
  3. Deploy to Staging
  4. Deploy to live

Some of the gates between jobs will be automatically triggered and some will be done manually using the Build Pipeline View. Please note the purpose of this post is to illustrate the process of creating a pipeline, the details of building artifacts, performing acceptance testing, automated deployment, etc will be saved for future posts.


  • Install Jenkins
  • Install the Build Pipeline plugin
  • Intall the Groovy plugin
  • Install the parameterized Trigger plugin

Build Job

The first job in your pipeline is usually responsible for setting the version number, building the artifact and deploying the artifact to an artifact repo. The build task may also include running unit tests, reporting code coverage and code analytics.

The first task is to create a new job as below:


After clicking OK you are forwarded on to the job configuration page. Add an “Execute system Groovy script” pre build step to create a release number and add it as a parameter of the job. In this example we use the Jenkins build number. You may want to use the Version Control revision number instead (assuming you are not using a distributed revision control system such as Git, which uses hashes instead of revision numbers).

This is achieved with the following script:

import hudson.model.AbstractBuild
import hudson.model.ParametersAction
import hudson.model.StringParameterValue
def build = Thread.currentThread().executable;
String release = "1.0." + build.number;
def currentBuild = Thread.currentThread().executable;
def newParamAction = new ParametersAction(new StringParameterValue("RELEASE_NO",release));

To set the release version of the artifact add an “Invoke top-level Maven targets” pre step with the command

versions:set -DnewVersion=$RELEASE_NO

Finally we add our “clean deploy” maven task.


Acceptance Test Job

The next job is responsible deploying the artifact from the artifact repo into a test environment and then running a suite of automated acceptance tests against the deployment.

The first task is to create the job.


I will save the details of automated deployment and automated acceptance testing for a later post.

We will now add a trigger from the Build job to the Acceptance Test job. From within the Build Job configuration add a “Trigger parameterized buid on other projects” post-build action. In “Projects to Build” specify “Acceptance Test”. Finally Click on “Add Parameters” and select “Current build parameters” to pass our release number to the next job.


Deploy to Staging Job

Create a new free-style project job to named “Deploy to Staging”. This job will be responsible for running the automated deployment and smoke test scripts against the staging environment. Again I will not cover these details in this post. This job should be a manually triggered gate in the pipeline. To do this open the Acceptance Test job configuration and create a new “Build Pipeline Plugin -> Manually Execute Downstream Project” Post-build action.


You can repeat the process with the “Deploy to Live” Job.

Create the Pipeline

The final task is to create the pipeline. From the Jenkins homepage create a new view by clicking on the “+” tab next to “All”. Give the view a name and specify a “Build Pipeline View”.


Clicking OK will take you to the pipeline configuration page. Make sure you specify the inital build as the “Build” job we created earlier.


Once the job is created go to the pipeline view and click the “Run” icon. This should run the “Build” and “Acceptace Test” tasks. To manually trigger the subsequent classes click the trigger button in the bottom right corner of the respective blue box.


Leave a Reply