简体   繁体   English

Jenkins Jira 步骤 - 声明式管道中的 Groovy 代码

[英]Jenkins Jira steps - Groovy code in Declarative Pipeline

Seems like Jira steps works only in Scripted pipeline .似乎Jira steps仅适用于Scripted pipeline How can I make use of JIRA steps inside Declarative pipeline ?如何在Declarative pipeline使用JIRA steps I get the error Unsupported map entry expression for CPS transformation when I try defining Jira steps inside pipeline.当我尝试在管道内定义 Jira 步骤时,我收到错误Unsupported map entry expression for CPS transformation

stages {    
    stage('Create JIRA Ticket'){            
        steps{          
            
            script {
                def jiraserver = "Demo"
                
                def testIssue = [fields [
                        project [id: '10101'],
                        summary: '[Test] Code Scan - $BUILD_NUMBER ',
                        description: 'Automated Pipeline',
                       customfield_1000: 'customValue',
                       issuetype: [id: '10000']]]
                    
                response = jiraNewIssue issue: testIssue
                echo response.successful.toString()
                echo response.data.toString()
                
                jiraAddComment site: 'Demo', idOrKey: 'Test-1', comment: 'Started Unit Tests'
            }
        }               
    }

I get the error WorkflowScript: 42: Unsupported map entry expression for CPS transformation in this context @ line 42, column 17 project [id: '10101'],我收到错误WorkflowScript: 42: Unsupported map entry expression for CPS transformation in this context @ line 42, column 17 project [id: '10101'],

You have several syntax issues on the testIssue parameter definition which causes the Unsupported map entry expression exception.您在testIssue参数定义上有几个语法问题,这会导致Unsupported map entry expression异常。
The issues is that fields and project are dictionary keys and should be followed with : .问题是fieldsproject是字典键,后面应该跟:
In addition if you wish to interpolate the BUILD_NUMBER in the summary use double quotes ( "" ).此外,如果您希望在摘要中插入BUILD_NUMBER ,请使用双引号 ( "" )。

The following should work:以下应该工作:

    def testIssue = [fields: [
                        project: [id: '10101'],
                        summary: "[Test] Code Scan - $BUILD_NUMBER",
                        description: 'Automated Pipeline',
                        customfield_1000: 'customValue',
                        issuetype: [id: '10000']]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM