---
sourceDocument: Australia IT Service Management
sourceDocumentLink: https://www.servicenow.com/docs/r/australia/it-service-management

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia IT Service Management

ft:clusterId :

    - itsm

bundleId :

    - itsm

workflow :

    - Technology


---

# Using a declarative or scripted pipeline in DevOps

# Using a declarative or scripted pipeline in DevOps {#ariaid-title1}

Release version: Australia  
Updated March 12, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Using a Declarative or Scripted Pipeline in DevOps

This content explains how to integrate Jenkins pipelines with ServiceNow DevOps using Jenkinsfiles for automated orchestration of tasks.
By defining pipelines in a Jenkinsfile stored in source control, each root-level stage becomes a discrete orchestration task in DevOps, simplifying the orchestration process and enabling automation of change management and artifact handling.
Show full answer Show less  
Setting the DevOps pipeline's **Track** field to True is essential to receive Jenkins job notifications, ensuring synchronization between Jenkins and DevOps.

## Key Features

* **Jenkinsfile Integration:** Jenkinsfiles map root-level pipeline stages to individual DevOps orchestration tasks automatically.
* **DevOps Jenkinsfile Commands:** Specialized commands enable detailed DevOps interactions within pipelines:
  * `snDevOpsChange` -- Manages change control with options to ignore errors and specify change request details.
  * `snDevOpsArtifact` and `snDevOpsPackage` -- Handle artifact registration and packaging.
  * `snDevOpsGetChangeNumber` and `snDevOpsUpdateChangeInfo` -- Retrieve and update change request information during pipeline execution.
  * `snDevOpsSecurityResult` -- Integrates security scanning results into DevOps Change Velocity metrics.
* **Jenkins Server Configuration:** Jenkins server configurations can be specified per step; a default is used if none is provided. Incorrect configurations cause step failures unless error ignoring is enabled.
* **Stage Support:** Only root-level stages are supported for mapping; nested or parallel stages are not mapped individually but associated with their parent root-level stage.
* **Jenkins Snippet Generator:** Provides templates for DevOps orchestration task steps, facilitating quick pipeline scripting without manual code creation.

## Parallel and Sub-stage Behavior

For nested stages (sub-stages) or parallel stages within a pipeline, DevOps creates only one change request at the root-level stage. All orchestration tasks generated by nested or parallel stages are linked to the parent root-level stage. This means:

* Change requests reflect parent stage details, not the nested or parallel sub-stage specifics.
* Multiple parallel sub-stages triggering changes result in a single change request associated with the parent stage.
* There is no distinction in DevOps about which parallel sub-stage triggered a change request.

## Practical Takeaways for ServiceNow Customers

* Use Jenkinsfiles to automate orchestration tasks and change management in DevOps efficiently.
* Ensure the pipeline's Track field is enabled to capture Jenkins job notifications properly.
* Leverage DevOps Jenkinsfile commands to manage change requests, artifacts, and security scans directly from pipelines.
* Use the Jenkins Snippet Generator to quickly create pipeline step code, reducing manual errors and speeding up pipeline development.
* Understand that only root-level pipeline stages map directly to DevOps orchestration tasks, with nested and parallel stages aggregated under their parent stages for change management.
* Specify Jenkins server configurations carefully to avoid pipeline failures or use error ignoring options when appropriate.  
When you use a Jenkinsfile, steps are created, mapped, and associated to
orchestration tasks automatically instead of manually.

Jenkinsfile is a text file that contains the definition of a Jenkins pipeline and is checked into source control.

Each root-level stage configured in the Jenkinsfile is discovered as a separate orchestration task in DevOps that is mapped to an individual step.  
Note:  
The Track field for the pipeline must be set to True in DevOps to receive job notifications from Jenkins. All active Jenkins configurations will receive job notifications when this field is set to True.

## DevOps Jenkinsfile commands {#dev-ops-scripted-pipeline__section_ccb_2yn_r3b}

* snDevOpsChange(ignoreErrors:{true/false},changeRequestDetails:{setCloseCode:{true/false},attributes:})

  Where ignoreErrors specifies the setting to prevent job failure if there is an error (true/false)

  Where changeRequestDetails specifies [closure code and change request fields](https://www.servicenow.com/docs/JrPZPSHCjQRzCnCP7jFB5Q "Configure how the closure information, change state, and change request fields are updated from within a pipeline in the change step of the pipeline.") from within the pipeline

  Enables change control for each root-level stage that is mapped to a DevOps step.
* snDevOpsArtifact

  Registers artifacts when configuring [Artifacts and packages](https://www.servicenow.com/docs/ZGDdOnEWq330BJleYqX2_g "Artifacts and packages enable DevOps Change Velocity to track development and testing activities across a wide range of deployment and release models. This feature ensures that pipeline activity stored in the DevOps data model can be retrieved and applied when artifacts are created and released at different times or in different pipelines.").
* snDevOpsPackage

  Creates a package for artifacts when configuring [Artifacts and packages](https://www.servicenow.com/docs/ZGDdOnEWq330BJleYqX2_g "Artifacts and packages enable DevOps Change Velocity to track development and testing activities across a wide range of deployment and release models. This feature ensures that pipeline activity stored in the DevOps data model can be retrieved and applied when artifacts are created and released at different times or in different pipelines.").
* snDevOpsGetChangeNumber

  Retrieves the change request number in a Jenkins pipeline based on specific change details.
* snDevOpsUpdateChangeInfo

  Updates the change request details associated with a Jenkins pipeline.
* snDevOpsSecurityResult

  Configures security scans on any stage of the pipeline and the scan details are retrieved from the corresponding stage to DevOps Change Velocity.
{#dev-ops-scripted-pipeline__ul_kbx_py3_r3b}

You can specify the Jenkins server configuration in any of these steps by passing the configurationName attribute in your pipeline. If the configuration name is not specified in any step, the default
configuration will be used in that step. Passing an incorrect configuration name will result in the step to fail unless the Ignore ServiceNow DevOps errors option is selected while configuring the Jenkins plugin.  
Note:  
Stage mapping is only supported for stages at the root level, not nested or parallel stages.

## Jenkins snippet generator for DevOps {#dev-ops-scripted-pipeline__section_vcx_kgw_f5b}

You can use the Jenkins Snippet Generator utility to generate a template code for the orchestration tasks for scripted pipelines. You can use the snippet generator utility to create template for the following orchestration tasks.

* SnDevOpsArtifact
* SnDevOpsChange
* SnDevOpsPackage
* snDevOpsGetChangeNumber
* snDevOpsUpdateChangeInfo
* snDevOpsSecurityResult

{#dev-ops-scripted-pipeline__ul_i1g_fjw_f5b}To generate a step snippet, navigate to the Pipeline Syntax from a configured pipeline, select the step from the Sample Step list, and update the values for different variables in the step. Select the ignore error option to prevent job failure if there is an error. Select Generate Pipeline Script to create a snippet. You can copy and paste the snippet into a pipeline.  
Example of a pipeline script for the SnDevOpsChange task:

    snDevOpsChange changeCreationTimeOut: 3600, changeRequestDetails: '{ "attributes": { "short_description": "Test description", "priority": "1", "start_date": "2021-02-05 08:00:00", "end_date": "2022-04-05 08:00:00", "justification": "test justification", "description": "test description", "cab_required": true, "comments": "This update for work notes is from jenkins file", "work_notes": "test work notes", "assignment_group": "a715cd759f2002002920bde8132e7018" }, "setCloseCode": false, "autoCloseChange": true }', changeStepTimeOut: 18000, configurationName: 'Jenkins1', pollingInterval: 60

## Parallel and sub-stage support {#dev-ops-scripted-pipeline__section_yyr_gvy_jjb}

When a stage (or set of parallel stages) is nested within a pipeline stage, these rules apply:  
* Any action from the nested stage is processed as part of the parent root-level stage
* Only one change request is created (at the parent root level) even if multiple stages nested under the parent root-level stage trigger a change
* Orchestration tasks created are always associated with the parent root-level stage (not the nested stage)
{#dev-ops-scripted-pipeline__ul_yb1_5xy_jjb}  

## Sub stage {#dev-ops-scripted-pipeline__example_vxg_yty_2bc}

In this sub-stage example, if a change request gets created from the sub stage (deploy PROD), the
details of the parent root-level stage (deploy) are used in the change request, and orchestration tasks are also associated with the parent root-level stage (deploy).  


    stage("deploy") {
             stages{
                 stage('deploy UAT') {
                    when{
                       branch 'dev'
                    }
                stage('deploy PROD') {
                   when {
                      branch 'master'
                   }
                    steps{
                      
                      snDevOpsChange()              
                    }
                }
            }

## Parallel stage {#dev-ops-scripted-pipeline__example_wxg_yty_2bc}

In this parallel stage example, if a change request is created from a sub stage (UAT test-1 and/or
UAT static code test), only the first change request is created (using the details of the parent root-level stage, UAT test) regardless of whether both sub stages (UAT test-1 and UAT static code test) get triggered.

There is no indication of which parallel stage generated the change, and orchestration tasks are associated with the parent root-level stage (UAT test).  


    stage('UAT test') {
          parallel {
              stage('UAT test-1') {
                  steps {
                      snDevOpsChange()
                      // 'UAT test-1' tasks
                  }
                    post {
                      success {
                        // post success tasks. E.g.: junit '**/target/surefire-reports/*.xml'
                      }
                  }
              }
              stage('UAT static code test') {
                  steps {
                      snDevOpsChange()
                      // 'UAT static code test' tasks
                  }
              }
          }
     }


