如何使用Jenkins Jira Steps插件

时间:2017-06-21 07:10:10

标签: jenkins jira jenkins-pipeline

我想使用Jenkins Jira Steps Plugin创建一个新的Jira问题。

这是我的演示管道:

node {
  stage('JIRA') {
    def testIssue = [fields: [ project: [id: '1'],
                                 summary: 'New JIRA Created from Jenkins.',
                                 description: 'New JIRA Created from Jenkins.',
                                 issuetype: [id: '11']]]

      response = jiraNewIssue issue: testIssue, site: 'JIRA T'

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

运行管道后,我得到:

[Pipeline] node
Running on master in /home/tomcat/.jenkins/workspace/Jira-RFC-Demo-Pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (JIRA)
[Pipeline] jiraNewIssue
JIRA: Site - JIRA T - Creating new issue: IssueInput(update=null, fields={project={id=1}, summary=New JIRA Created from Jenkins., description=New JIRA Created from Jenkins., issuetype={id=11}})
Error Code: 400
Error Message: {"errorMessages":[],"errors":{"project":"project is required"}}
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: {"errorMessages":[],"errors":{"project":"project is required"}}
Finished: FAILURE

所以看起来这个插件无法从testIssue中读取项目。然而,这应该是创建上述链接中记录的问题的方法。

任何想法?

1 个答案:

答案 0 :(得分:1)

我认为错误信息具有误导性。 以下是诀窍:

node {
  stage('JIRA') {
    def testIssue = [fields: [ project: [key: 'RFC'],
                                 summary: 'New JIRA Created from Jenkins.',
                                 description: 'New JIRA Created from Jenkins.',
                                 issuetype: [id: '10500']]]

      response = jiraNewIssue issue: testIssue, site: 'JIRA T'

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

区别在于使用密钥而不是project-id。 所以也许id不存在或无效。

无论如何,我认为使用密钥更具表现力。