2017-06-21 119 views
0

我想使用Jenkins Jira Steps Plugin創建新的Jira問題。如何使用Jenkins Jira Steps插件創建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項目。儘管如此,這應該是創建問題的方式,如上面的鏈接所述。

任何想法?

回答

0

我認爲錯誤信息是誤導性的。 下面的伎倆:

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() 
    } 
} 

的區別是使用鍵,而不是項目的ID。 所以也許這個ID根本不存在或無效。

無論如何,我認爲使用密鑰更具表現力。