Updating Jira tickets from Jenkins workflow (jenkinsfile)

前提是你 提交于 2019-12-03 16:50:47

The Jira Plugin is compatible with Pipeline.

This should work:

step([$class: 'hudson.plugins.jira.JiraIssueUpdater', 
    issueSelector: [$class: 'hudson.plugins.jira.selector.DefaultIssueSelector'], 
    scm: [$class: 'GitSCM', branches: [[name: '*/master']], 
        userRemoteConfigs: [[url: 'https://github.com/jglick/simple-maven-project-with-tests.git']]]]) 

You can get a full reference in the built-in Pipeline Snippet Generator.

Yes, seems like this page answers your question:

https://wiki.jenkins-ci.org/display/JENKINS/Jira+Issue+Updater+Plugin

After you install the plugin, add a build step, or pre/post build step to call this plugin

There you can give it the REST URL to your Jira server, the creds and the JQL to find the issues

The JIRA Steps Plugin provides a more declarative way to update an existing Jira Ticket:

node {
  stage('JIRA') {
    # Look at IssueInput class for more information.
    def testIssue = [fields: [ // id or key must present for project.
                               project: [id: '10000'],
                               summary: 'New JIRA Created from Jenkins.',
                               description: 'New JIRA Created from Jenkins.',
                               customfield_1000: 'customValue',
                               // id or name must present for issuetype.
                               issuetype: [id: '3']]]

    response = jiraEditIssue idOrKey: 'TEST-01', issue: testIssue

    echo response.successful.toString()
    echo response.data.toString()
  }
}

Since you would like to use the Jenkinsfile to define your pipeline, that should be the preferred way for you to go...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!