Configuring Jenkins
If you are using a Run Jenkins step task in your pipeline, configure Jenkins so that it can communicate with the orchestration server.
- On the orchestration server, create an authentication profile that uses Jenkins
credentials.
- If you are using a version of Jenkins earlier than 2.17.6, create an
authentication profile on the orchestration server that specifies the
credentials to use.
- Click .
- Enter a name, and then click Create and open.
- In the User name field, enter Jenkins user ID.
- Click Set password, enter the Jenkins password, and then click Submit.
- Click the Preemptive authentication check box.
- Click Save.
- Go to step 4.
For more information about configuring authentication profiles, see Creating an authentication profile.
- If you are using Jenkins 2.17.6 or later and want to use an API token for authentication, go to step 2.
- If you are using Jenkins 2.17.6 or later and want to use a Crumb Issuer for authentication, go to step 3.
- If you are using a version of Jenkins earlier than 2.17.6, create an
authentication profile on the orchestration server that specifies the
credentials to use.
- If you are using Jenkins version 2.17.6 or later and want to use an API token
for authentication, do the following steps:
- Log in to the Jenkins server.
- Click People, click the user who is running the Jenkins job, and then click .
- Generate the API token.
- Create an authentication profile on the orchestration server by clicking .
- In the User name field, enter the Jenkins user ID.
- Click Set password, enter the API token that you generated, and then click Submit.
- Click the Preemptive authentication check box.
- Click Save.
- Go to step 4.
For more information about configuring authentication profiles, see Creating an authentication profile.
- If you are using Jenkins version 2.17.6 or later and want to use a Crumb Issuer
for authentication, do the following steps:
- Log in to the Jenkins server.
- Click and select the check box for the Strict Crumb Issuer plug-in.
- Click .
- In the CSRF protection section, in the Crumb Issuer list, select Strict Crumb Issuer.
- Click Advanced, and then clear the Check the session ID check box.
- Click Save.
- Create an authentication profile on the orchestration server by clicking .
- In the User name field, enter the Jenkins user ID.
- Click Set password, enter the Jenkins password, and then click Submit.
- Click the Preemptive authentication check box.
- Click Save.
- Go to step 4.
For more information about configuring authentication profiles, see Creating an authentication profile.
- Install the Post build task plug-in.
- Install the curl command on the Jenkins server.
- Create a new freestyle project.
- On the General tab, select the This project is parameterized check box.
- Add the BuildID and CallBackURL parameters.
- Click Add parameter, and then select String parameter.
- In the String field, enter BuildID.
- Click Add parameter, and then select String parameter.
- In the String field, enter CallBackURL.
- To add parameters that you can use in Run
Jenkins step tasks in the pipeline, click Add parameter,
select String parameter, and enter the string of the
parameter. The system automatically populates these values in Jenkins tasks. You
can add any of the following strings:
- If you are using Jenkins tasks for continuous integration (you are
using branches), add any of the following strings:
- PipelineName: Pipeline name on which the Run Jenkins step task is configured.
- ApplicationName: Application for which the pipeline is configured.
- RepositoryName: Repository to which the merged branch is published.
- BranchName: Branch for which the Run Jenkins step task is configured.
- BranchFilePath: Location of the branch.
- OrchestratorURL: URL of the orchestration server. Add this parameter to stop a pipeline when the Run Jenkins step fails in a pipeline.
- PipelineID: ID of the pipeline on which the Run Jenkins step task is configured.
- If you are using Run Jenkins step tasks for continuous delivery (in
staging, QA, or production environments), add any of the following
strings:
- PipelineName: Pipeline name on which the Run Jenkins step task is configured.
- RepositoryName: Repository that the Deploy task uses for the stage (for example, staging) on which the Run Jenkins step task is configured.
- DeploymentID: ID of the current deployment.
- DeploymentArtifactName: Artifact name that the Deploy task uses on the stage on which the Run Jenkins step task is configured.
- StartedBy: ID of the operator who started the deployment.
- CurrentStage: Name of the stage on which the Run Jenkins step task is configured.
- ArtifactPath: Full path to the artifact that the Deploy task uses.
- OrchestratorURL: URL of the orchestration server. Add this parameter to stop a pipeline when the Run Jenkins step fails in a pipeline.
- PipelineID: ID of the pipeline on which the Run Jenkins step task is configured. Add this parameter to stop a pipeline when the Run Jenkins step task fails in a pipeline.
- If you are using Jenkins tasks for continuous integration (you are
using branches), add any of the following strings:
- In the Build Triggers section, select the Trigger builds remotely check box.
- In the Authentication Token field, select the token that you want to use when you start Jenkins jobs remotely.
- In the Build Environment section, select the Use Secret text(s) or file(s) check box.
- In the Bindings section, do the following actions:
- Click Add, and then select User name and password (conjoined).
- In the Variable field, enter RMCREDENTIALS
- In the Credentials field, click Specific credentials.
- Click Add, and then select Jenkins.
- In the Add credentials dialog box, in the Username field, enter the operator ID of the release manager operator that is configured on the orchestration server.
- In the Password field, enter the password.
- Click Save.
- Add post-build tasks by doing one of the following actions:
- If Jenkins is running on Microsoft Windows, go to step 15.
- If Jenkins is running on Linux, go to step 16.
- If Jenkins is running on Microsoft Windows, add the following post-build tasks:
- Click Add post-build action, and then select Post build task.
- In the Post-Build Actions section, in the Log text field, enter a unique string for the message that is displayed in the build console output when a build fails, for example BUILD FAILURE.
- In the Script field, enter curl --user %RMCREDENTIALS% -H "Content-Type: application/json" -X POST --data "{\"jobName\":\"%JOB_NAME%\",\"buildNumber\":\"%BUILD_NUMBER%\",\"pyStatusValue\":\"FAIL\",\"pyID\":\"%BuildID%\"}" "%CallBackURL%".
- Click Add another task.
- In the Post-Build Actions section, in the Log text field, enter a unique string for the message that is displayed in the build console output when a build is successful, for example BUILD SUCCESS.
- In the Script field, enter curl --user %RMCREDENTIALS% -H "Content-Type: application/json" -X POST --data "{\"jobName\":\"%JOB_NAME%\",\"buildNumber\":\"%BUILD_NUMBER%\",\"pyStatusValue\":\"SUCCESS\",\"pyID\":\"%BuildID%\"}" "%CallBackURL%"
- Click Save.
- Go to step 17.
- If Jenkins is running on Linux, add the following post-build tasks. Use the
dollar sign ($) instead of the percent sign (%) to access the environment
variables:
- Click Add post-build action, and then select Post build task.
- In the Log text field, enter a unique string that for the message that is displayed in the build console output when a build fails, for example BUILD FAILURE.
- In the Script field, enter curl --user $RMCREDENTIALS -H "Content-Type: application/json" -X POST --data "{\"jobName\":\"$JOB_NAME\",\"buildNumber\":\"$BUILD_NUMBER\",\"pyStatusValue\":\"FAIL\",\"pyID\":\"$BuildID\"}" "$CallBackURL"
- Click Add another task.
- In the Log text field, enter a unique string that for the message that is displayed in the build console output when a build is successful, for example BUILD SUCCESS.
- In the Script field, enter curl --user $RMCREDENTIALS -H "Content-Type: application/json" -X POST --data "{\"jobName\":\"$JOB_NAME\",\"buildNumber\":\"$BUILD_NUMBER\",\"pyStatusValue\":\"SUCCESS\",\"pyID\":\"$BuildID\"}" "$CallBackURL"
- Click Save.
- Go to step 17.
- To stop a pipeline deployment if a Jenkins build fails, add a post-build
script:
- Click Add post-build action, and then select Post build task.
- In the Log text field, enter a unique string for the message that is displayed in the build console output when a build fails, for example JENKINS BUILD FAILURE.
- In the Script field, enter curl --user %RMCREDENTIALS% -H "Content-Type: application/json" -X PUT --data "{"AbortNote":"Aborted from jenkins job"}" %OrchestratorURL%/PRRestService/cicd/v1/pipelines/%PipelineID%/builds/%DeploymentID%/abort
- Click Save.
Previous topic Understanding email notifications Next topic Configuring and running pipelines with Deployment Manager 4.8.x