This tutorial shows how to setup and deploy a parametrized Jenkins job from an HCL Accelerate pipeline.

Requirements

1. Create Jenkins Job for PROD Deployment

1.1 Create a New Pipeline Job

Create a second pipeline job, this time for deployment to a fictitious production or “PROD” environment.

https://urbancode.github.io/velocity-info/workbooks/jenkins/newItem.PNG

https://urbancode.github.io/velocity-info/workbooks/jenkins/jkeApp1Prod.png

1.2 Configure the Pipeline Script

Copy and paste the script below as a pipeline script. Similar to the script we used for Build, DEV, and QA – The PROD script has two variable values that we must get from the “Download attributes for API” json file. Recall that this file can be downloaded from the tool icon in your HCL Accelerate value stream. After copying and pasting the script and providing correct variable values, click “Apply” and “Save” in Jenkins.

Variable Name Description Example
VSM_ENV_ID_PROD An ID that uniquely identifies your value stream’s PROD environment 7a115f90-f4e5-4181-9920-78b216bb4afc
VSM_APP_NAME The HCL Accelerate pipeline application name (use “JKE App1” for the workbook, we will create this pipeline application later) JKE App1

SCRIPT

parameters([

string(name: 'buildNumber', description: 'The version of the application to deploy.')

])

node {

//Get value for VSM_ENV_ID_PROD from HCL Accelerate VSM "Download attributes from API" json file.

def VSM_ENV_ID_PROD="0e9ea7c7-ed1d-43f2-9ebf-a5ab5161d61e"

//VSM_APP_NAME must match your HCL Accelerate pipeline application name

def VSM_APP_NAME="JKE App1"




currentBuild.displayName = "${buildNumber}"

stage ("Deploy to PROD") {

step([$class: 'UploadDeployment',

//"versionExtId" can be used in place of "id" and "versionName"

id: "${currentBuild.displayName}",

versionName: "${currentBuild.displayName}",

name: "${currentBuild.displayName}",

description: 'UploadBuild Example',

tenantId: "5ade13625558f2c6688d15ce",

initiator: "admin",

//Must specify one of "appId", "appExtId", or "appName"

appName: "${VSM_APP_NAME}",

environmentName: 'PROD',

environmentId: "${VSM_ENV_ID_PROD}",

result: "${currentBuild.currentResult}".toLowerCase(),

startTime: "${currentBuild.startTimeInMillis}",

endTime: "${System.currentTimeMillis()}",

type: "Jenkins",

debug: false,

fatal: false,

])

}

}

 

1.3 Parameterize the Job

Make the pipeline job parameterized with a string parameter named “buildNumber”. Click “Apply” and “Save”.
https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/parameterizedJob.png

2. Setup HCL Accelerate Pipeline

We will setup our PROD deployment a little differently than we setup our DEV and QA deployments. For this tutorial, we will setup an input job (previous build or deployment) that will provide a version to our pipeline. The pipeline will also include a parameterized PROD deployment that will pass the build number to the Jenkin job. We will be able to see an available input version to our pipeline and deploy this version to a PROD environment all from within HCL Accelerate, using Jenkins as the server, and observe actual server activity from within our value stream.

2.1 Configure the Input Job

2.1.1 From the pipeline, click on the “+” underneath “Input” for the application of interest (“JKE App1” in this example).

https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/1.png

2.1.2 In the “Create Version” form choose “Automatically” and select the Jenkins job that is generating the build. For this tutorial, use the Build, DEV, QA Jenkins job that we previously created.

https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/1b.png https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/2.png

2.2 Configure PROD deployment

We need to assign (map) the Jenkins job that will deploy to PROD to the HCL Accelerate pipeline environment for PROD. We also need to configure this job to use a pipeline parameter for build number.

2.2.1 From the pipeline, click on the “+” underneath “PROD” for the application of interest (“JKE App1” in this example).

https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/3.png

2.2.2 Select the job we created for deploying to PROD and click “Save”.
https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/4.png

2.2.3 We are going to link builds to deployments by passing the buildNumber as a parameter to a Jenkins job. Since we configured our job with parameters, we will be prompted at this point to provide them. HCL Accelerate has various version/inventory parameters on hand to support a fluid pipeline. In this case we will enter ${version.buildNumber} into the form.
https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/paramForm.png

You should now see “Not yet Run” under both “Input” and “PROD” columns. Go ahead and run the first Jenkins job (the input job) to provide new build information to HCL Accelerate. After running the input job, you should see version information.

  • Before Running Jenkins Job
    https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/5.png
  • After Running Jenkins Job
    https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/6.png

3. Final Stage Change to PROD

3.1 Pipeline Deployment to PROD

3.1.1 From your HCL Accelerate pipeline, click on the “Play” button for PROD.

https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/deploy1.png

3.1.2 Select the latest version and click “Deploy”. This will start the parameterized Jenkins job we created.
https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/deploy2.png

3.1.3 After the job has finished the pipeline should show “Deployment succeeded” along with a version number.
https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/deploy3.png

Going back to the value stream we should see the dot move all the way to PROD, its final stage.

https://urbancode.github.io/velocity-info/workbooks/jenkins/pipeline/deploy4.png

Conclusion

This concludes our Jira, GitHub, Jenkins tutorial series. We navigated an entire value stream journey from backlog to production and used four separate tools along the way: three external tools (Jira, GitHub, and Jenkins), and HCL Accelerate itself as a deployment tool. We learned about key HCL Accelerate concepts such as the vsm.json file with its stage queries, integrations, and linkRules, as well as pipelines and deployments. From here you can go back and begin experimenting with your value stream. One good place to start is by looking at the vsm.json file stages and queries. From there you can begin to shape the value stream to match your own processes.

 

Comment wrap
Further Reading
Secure DevOps | September 15, 2020
Survey says…here’s what the market really thinks of Value Stream Management
HCL Software DevOps partnered with SD Times on the Value Stream Management Market Study on VSM adoption and awareness. Read on to see the results.
Secure DevOps | September 14, 2020
HCL Accelerate VSM with Jenkins – Part 1
This tutorial shows how to create a Jenkins pipeline job to upload build and deployment data with HCL Accelerate, our value stream management platform.
Secure DevOps | September 11, 2020
Integrating HCL AppScan on Cloud (ASoC) with HCL Accelerate
With secuity scanning + value stream management, HCL AppScan works amazingly well with HCL Accelerate to enhance your software delivery pipeline.
a/icon/common/search Created with Sketch.