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:
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] }
...