Reputation: 75
I'm shifting from maven jobs to pipeline jobs. in maven jobs we have used Jira update relevant issues
plugin in post build actions step which will update the jenkins current build status to all the jira issues mentioned in the commits messages.
I'm trying to implement the same in pipeline script, i did tried something like below but it didn't help.
stage('Jira: Update relevant issues') {
steps {
script {
try {
step([$class: 'hudson.plugins.jira.JiraIssueUpdater',
issueSelector: [$class: 'hudson.plugins.jira.selector.DefaultIssueSelector'],
scm: [$class: 'GitSCM', branches: [[name: '<branch name>']],
userRemoteConfigs: [[url: '<clone url>']]]])
} catch (Exception e) {
echo "Error updating Jira issues: ${e}"
}
}
}
}
and i have installed multiple jira plugins in my jenkins env and tried using pipeline steps to utilize it, but no joy.
Note: I did notice that everywhere in piplescript they were mentioning the jira issue id/key, but here whatever the commit changes triggered the jenkins build will have jira ticket in commit message. All those jira tickets should have updated with the build status in its comment section.
Upvotes: 1
Views: 813
Reputation: 3445
If you have tried all the different Jira plugins out there and none of them work, you could consider directly calling the Jira API. The API is actually more stable than using a plugin, although it isn't as simple. If you are using Jira server, you can read about how to do it here. If you are using cloud, follow the documentation here.
You should use the httprequest plugin with Jenkins to send the POST requests to the Jira API.
Upvotes: 0