user2730471 user2730471 - 2 months ago 41x
Groovy Question

Updating Jira ticket from jenkins 2 pipeline

Hi I am implementing a jenkins 2 pipeline. I am trying to create a groovy function that will update a given story in Jira. I found the below code which I have been told should work.

step([$class: 'hudson.plugins.jira.JiraIssueUpdater',
issueSelector: [$class: 'hudson.plugins.jira.selector.DefaultIssueSelector'],
scm: [$class: 'GitSCM', branches: [[name: '*/master']],
userRemoteConfigs: [[url: '']]]])

I am wondering how is the ticket specified using this?
Would anyone be able to describe what is happening in this code?


I have never used Jira pipeline-compatible plugin but from the plugin's pipeline documentation it appears that you can pass a number of parameters to Jira's updater such as :

  • Jira REST base url
  • Jira Username/Password
  • JQL for selecting issues to be updated
  • Jira comment to be added

I think a close look to this documentation file will give you all the information you need, and once you know which parameters you should be able to call Jira updater with this kind of Groovy code :

step([$class: 'hudson.plugins.jira.JiraIssueUpdater',
  restAPIUrl: yourJiraAPIUrl,
  jql: theJQLQueryThatWillFindYourIssuesToUpdate,
  comment: theComment,
  failIfJqlFails: true

The sample you provide does not seem to be correct because the two parameters issueSelector and scm are not valid parameters of the JiraIssueUpdater class.