Jenkins to Jira integration: how to send deployment info for only the environment being deployed to?

burt repine September 27, 2024

As we only deploy to 1 environment at a time we would like the Jira info sent for only that environment.

Currently it sends info for all environments if we write our pipeline syntax, using stages, as described here:

How Jenkins for Jira works 

We use a 'when' conditional to direct the script to the particular environment we would like to deploy to a la:

 

...
stage('deploy to DEV') {
when { expression { "$envName" == "DEV" } }
steps {
// deploy to DEV....only send Jira info for DEV
...
}
}
stage('deploy to QA') {
when { expression { "$envName" == "QA" } }
steps {
// deploy to QA....only send Jira info for QA
...

 

 

But in this scenario, deployment info is sent to Jira for BOTH environments which is really misleading.

Console output for a DEV deploy where deployment info for QA is also sent to Jira even though the Stage "deploy to QA" was properly skipped:

...
[Pipeline] stage
[Pipeline] { (deploy to QA)
...
[ATLASSIAN CLOUD PLUGIN] [DEBUG] Extracted issue keys from ChangeLogSet message 'SPA-1371: testing': [SPA-1371]
[ATLASSIAN CLOUD PLUGIN] [INFO] sending request to Jenkins app in Jira: {DEPLOYMENT DETAILS...
Stage "deploy to QA" skipped due to when conditional
[Pipeline] getContext
[Pipeline] }
...

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events