简体   繁体   English

如何将 MAP 参数传递给 jira 从 groovy 脚本创建新问题方法

[英]how to pass MAP argument to jira create new issue method from groovy script

on call to createJiraIssue getting error from jira's end, need to know correct way of passing update keys and value to jira create new issue在调用 createJiraIssue 从 jira 端收到错误时,需要知道将更新键和值传递给 jira 创建新问题的正确方法

Early help would be great thing for me.....早期的帮助对我来说是件好事......

def MapUpdateData = [
                 "issuelinks": [
                     "add": [
                          "type": [
                               "name": "Blocks",
                               "inward": "is blocked by",
                               "outward":"blocks"
                          ],
                          "outwardIssue": [
                              "key": "TEST-123"
                          ]
                     ]
                 ]
             ]

createJiraIssue(
   projectKey: 'TEST',
   issueType: 'Story',
   component: 'My-test',
   summary: 'It is a test',
   update: MapUpdateData
)
 
def createJiraIssue(Map args) {
        def issue = [
            fields: [
                project: [key: args.projectKey],
                summary: args.summary,
                issuetype: [name: args.issueType],
                components: [[name: args.component]]
            ]
        ]
        if (args.update) {
            issue.put("update", args.update)
        }
        response = jiraNewIssue(issue: issue)
        ......

error:
Error Message: {"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@55e53c2e; line: 1, column: 12] (through reference chain: com.atlassian.jira.rest.v2.issue.IssueUpdateBean[\"update\"])"]}

You are using list to create request JSON;您正在使用列表创建请求 JSON; however you should use maps/dicts.但是你应该使用地图/字典。

For example:例如:

Your query is giving:您的查询给出:

"fields":[
project: ["TEST"],
...
]

However, it should be:但是,它应该是:

"fields":{
   project: "TEST",
   ...
}

Same thing applies on your update JSON:同样的事情也适用于您的更新 JSON:

Instead of yours;而不是你的;

you should use:你应该使用:

def MapUpdateData = {
    "issuelinks": {
        "add": {
            "type": {
                "name": "Blocks",
                "inward": "is blocked by",
                "outward":"blocks"
            },
            "outwardIssue": {
                "key": "TEST-123"
            }
        }
    }
}

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

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