Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Configuring Jenkins

Updated on February 4, 2021

If you are using a Run Jenkins step task in your pipeline, configure Jenkins so that it can communicate with the orchestration server.

  1. 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.
      1. Click CreateSecurityAuthentication Profile.
      2. Enter a name, and then click Create and open.
      3. In the User name field, enter Jenkins user ID.
      4. Click Set password, enter the Jenkins password, and then click Submit.
      5. Click the Preemptive authentication check box.
      6. Click Save.
      7. 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.
  2. If you are using Jenkins version 2.17.6 or later and want to use an API token for authentication, do the following steps:
    1. Log in to the Jenkins server.
    2. Click People, click the user who is running the Jenkins job, and then click ConfigureAPI token.
    3. Generate the API token.
    4. Create an authentication profile on the orchestration server by clicking CreateSecurityAuthentication Profile.
    5. In the User name field, enter the Jenkins user ID.
    6. Click Set password, enter the API token that you generated, and then click Submit.
    7. Click the Preemptive authentication check box.
    8. Click Save.
    9. Go to step 4.

      For more information about configuring authentication profiles, see Creating an authentication profile.

  3. If you are using Jenkins version 2.17.6 or later and want to use a Crumb Issuer for authentication, do the following steps:
    1. Log in to the Jenkins server.
    2. Click Manage JenkinsManage Plugins and select the check box for the Strict Crumb Issuer plug-in.
    3. Click Manage JenkinsConfigure Global Security.
    4. In the CSRF protection section, in the Crumb Issuer list, select Strict Crumb Issuer.
    5. Click Advanced, and then clear the Check the session ID check box.
    6. Click Save.
    7. Create an authentication profile on the orchestration server by clicking CreateSecurityAuthentication Profile.
    8. In the User name field, enter the Jenkins user ID.
    9. Click Set password, enter the Jenkins password, and then click Submit.
    10. Click the Preemptive authentication check box.
    11. Click Save.
    12. Go to step 4.

      For more information about configuring authentication profiles, see Creating an authentication profile.

  4. Install the Post build task plug-in.
  5. Install the curl command on the Jenkins server.
  6. Create a new freestyle project.
  7. On the General tab, select the This project is parameterized check box.
  8. Add the BuildID and CallBackURL parameters.
    1. Click Add parameter, and then select String parameter.
    2. In the String field, enter BuildID.
    3. Click Add parameter, and then select String parameter.
    4. In the String field, enter CallBackURL.
  9. 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:
    1. 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.
    2. 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.
  10. In the Build Triggers section, select the Trigger builds remotely check box.
  11. In the Authentication Token field, select the token that you want to use when you start Jenkins jobs remotely.
  12. In the Build Environment section, select the Use Secret text(s) or file(s) check box.
  13. In the Bindings section, do the following actions:
    1. Click Add, and then select User name and password (conjoined).
    2. In the Variable field, enter RMCREDENTIALS
    3. In the Credentials field, click Specific credentials.
    4. Click Add, and then select Jenkins.
    5. 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.
    6. In the Password field, enter the password.
    7. Click Save.
  14. Add post-build tasks by doing one of the following actions:
    1. If Jenkins is running on Microsoft Windows, go to step 15.
    2. If Jenkins is running on Linux, go to step 16.
  15. If Jenkins is running on Microsoft Windows, add the following post-build tasks:
    1. Click Add post-build action, and then select Post build task.
    2. 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.
    3. 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%".
    4. Click Add another task.
    5. 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.
    6. 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%"
    7. Click Save.
    8. Go to step 17.
  16. 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:
    1. Click Add post-build action, and then select Post build task.
    2. 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.
    3. 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"
    4. Click Add another task.
    5. 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.
    6. 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"
    7. Click Save.
    8. Go to step 17.
  17. To stop a pipeline deployment if a Jenkins build fails, add a post-build script:
    1. Click Add post-build action, and then select Post build task.
    2. 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.
    3. 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
    4. Click Save.
  • Previous topic Understanding email notifications
  • Next topic Configuring and running pipelines with Deployment Manager 4.8.x

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us