Model a Jenkins pipeline in DevOps

  • Release version: Washingtondc
  • Updated August 1, 2024
  • 3 minutes to read
  • Model a Jenkins pipeline by mapping the pipeline to an app, and mapping DevOps pipeline steps to Jenkins stages.

    Before you begin

    The Jenkins plugin for ServiceNow DevOps is provided to enable change acceleration so your orchestration tool can communicate with ServiceNow DevOps and control certain aspects of pipeline executions.

    Install the plugin from the Jenkins Marketplace. Navigate to Manage Jenkins > System configuration > Plugins in your Jenkins instance. Search for ServiceNow DevOps Plugin and select it, and then select Install.

    Ensure that your Jenkins tool is connected and configured. For more information, see Onboard Jenkins to DevOps Change Velocity — Workspace.

    Role required: sn_devops.admin

    About this task

    Both scripted pipelines (Jenkinsfile) and freestyle jobs are supported.

    For Jenkinsfile pipelines, pipeline steps are created, mapped, and associated to orchestration tasks automatically, instead of manually.

    Procedure

    1. Map your pipeline to an app in DevOps.
      1. Navigate to DevOps > Apps & Pipelines > Apps and open the application record to associate with the pipeline.
      2. In the Pipelines related list, click Edit... to select a pipeline to associate with the app, or click New to create the pipeline.
        For a new pipeline, fill in the Orchestration pipeline field using the full project name as specified in Jenkins.
        Note:
        While associating a pipeline with an app, the pipeline steps are also fetched during import.
      3. Click Submit.
    2. Open the pipeline record again and select the Track check box so events from the pipeline are received.
      Note:
      The Track check box must be selected to integrate the pipeline with DevOps.
    3. Create DevOps steps automatically or manually to map to each Jenkins pipeline stage so an orchestration task is created.
      • For declarative or scripted pipelines, run your Jenkins pipeline to automatically create and map pipeline steps in DevOps.

        Pipeline steps are automatically created, mapped, and associated when DevOps receives step notifications from your Jenkins pipeline during the run.

      • For freestyle jobs, manually create and map each pipeline step to a Jenkins pipeline job.

        In the Steps related list, click New to create a DevOps step for each Jenkins pipeline stage (Orchestration stage field)

        Note:
        The Orchestration stage field value of each step is case-sensitive and must match the original name of the corresponding Jenkins pipeline stage.
        Name Name of the pipeline step.
        Pipeline Pipeline in which the step is configured.
        Type Pipeline step type.
        • Build and Test
        • Test
        • Deploy
        • Deploy and Test
        • Manual
        • Prod Deploy
        Order

        Order in which the steps are run.

        Note:
        The step order determines the order of the cards in the Pipeline UI.

        The order of the cards in the Pipeline UI is by task execution.

        Orchestration stage

        Jenkins pipeline stage name (case-sensitive).

        Note:
        For step association with Jenkins pipeline stages, the Orchestration stage field must be configured.
        Business service Configuration service that applies to the step.

        Once orchestration tasks are created, associate each orchestration task in the Orchestration Tasks related list with a DevOps pipeline step.

    4. Optional: Enable change control automatically or manually based on the type of pipeline.
      • For declarative or scripted pipelines, if you have used the snDevOpsChange script in your pipeline, run your Jenkins pipeline to automatically enable change control. You can also enable change control manually by following the steps provided for freestyle jobs.
      • For freestyle jobs, select the Change control check box in a step to enable change acceleration and the corresponding configuration fields.
        Note:
        ServiceNow Change Management must be installed for change acceleration.
        Change receipt

        Select to enable change receipt for the step so the pipeline doesn't pause when a change request is created.

        All pipeline data is included in the change, but approval is not required for the pipeline to proceed.

        Change approval group

        Approval group for the change request.

        The change approval group becomes the Assignment group in the DevOps change request.

        Note:
        Ensure that the selected group has members and a group manager so the approver field is not empty.
        Change type Change request type to create.
        • Normal (default)
        • Standard
        • Emergency
        Change model Change model for the change request. For more information, see DevOps change models.

        Template

        Note:
        This field is shown only when Change type is Normal or Emergency.

        List of templates to use to auto populate fields for Normal or Emergency change requests.

        Select a template or create a new one.

        Standard change template

        Note:
        This field is shown only when Change type is Standard.
        List of standard change templates to use for Standard change requests.
        Note:
        This field is required for Standard change type.
        Change controlled branches

        (Multibranch only) Comma-separated list of branches under change control. Wildcards are supported.

    Example

    Figure 1. DevOps app
    DevOps pipeline
    Figure 2. DevOps pipeline
    DevOps Pipeline Steps
    Figure 3. DevOps pipeline step
    DevOps pipeline stages