• Get started
  • Documentation

Use deployment tracking with Jenkins

Changes to Free and Standard plans in Jira Service Management

As of October 16, 2024, change management for Jira Service Management will move from Standard to Premium plans. After this point, only Premium and Enterprise plans will have access to this feature.

Existing projects in Free and Standard plans will continue to support existing request types and issue types. Read more about the plan changes.

Deployment tracking lets you automatically create or update a change request from any stage in your Jenkins pipeline. Use deployment tracking if approval from stakeholders isn’t required before changes occur. If you need approval from stakeholders, use deployment gating.

To use deployment tracking with Jenkins:

  1. Go to your Jenkinsfile.

  2. Find the stage in your pipeline where you would like to notify Jira.

  3. Add a sendJiraDeploymentInfo block to the stage steps replacing your Jira site name, environment ID, environment type and service ID(s) you copied from your Jira Service Management project.

Snippet example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 stage('Production') { steps { // Notify Jira a new deployment has started jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'in_progress' ) sh 'echo Deploy to Production starting...' } post { always { sh 'sleep 2' sh 'echo Deployment to production finished' } success { echo 'Deployment successful' // Notify Jira if the deployment succeeded jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'successful' ) } failure { echo 'Deployment failed' // Notify Jira if the deployment succeeded jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'failed' ) } } } }

 

Full Jenkinsfile example

Notify Jira when the deployment to production starts and again when the deployment finishes. 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 pipeline { agent any stages { stage('Build') { steps { sh 'echo Run build...' } } stage('Test') { steps { sh 'echo Run tests...' } } stage('Stage') { steps { sh 'echo Deploy to Staging...' } } stage('Production') { steps { jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'in_progress' ) sh 'echo Deploy to Production starting...' } post { always { sh 'sleep 2' sh 'echo Deployment to production finished' } // Notify Jira based on deployment step result success { echo 'Deployment successful' jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'successful' ) } failure { echo 'Deployment failed' jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'failed' ) } aborted { echo 'Deployment cancelled' jiraSendDeploymentInfo ( environmentId: 'us-prod-1', environmentName: 'us-prod-1', environmentType: 'production', serviceIds: [ '<YOUR-SERVICE-ID>' ], site: '<YOUR-SITE>.atlassian.net', state: 'cancelled' ) } } } } }

 

Still need help?

The Atlassian Community is here for you.