Jenkins的Jira Trigger插件:从问题对象中获取值

时间:2016-11-29 13:34:17

标签: jenkins-jira-trigger

我正在尝试使用Jenkins的Jenkins和Jira Trigger插件设置一些自动化。我已经在Jira端建立了一个Web钩子,它可以根据需要调用Jenkins上的构建。

我从传入的Jira请求获取自定义字段的值时遇到了问题。

我试图使用"问题属性路径"功能,我也提到了帖子(How to use the 'Issue attribute path' in the parameter mapping of jenkins-trigger-plugin

Howevevr我仍然无法获得自定义字段customfield_10010customfield_10011的价值。我尝试过使用fields.customfield_10010fields.customfield_10010.valuefields.customfield_10010.0.valuecustomfield_10010.0.value和类似组合的映射。我可以像插件帮助中建议的那样获得其他标准字段的价值。例如:status.namedescription等。

我无法从Jira documentation site获得任何线索。

传入的json数据部分在下面,以便于参考。

  "issue": {
            "id": "1000x",
            "self": "http://localhost:3080/rest/api/2/issue/10007",
            "key": "ABC-2",
            "fields": {
                "issuetype": {
                    ..
                },
                "parent": {
                    ..
                },
                "components": [

            ],
            "timespent": null,
            "timeoriginalestimate": 28800,
            "description": ".....",
            "project": {
                ..
            },
            "customfield_10010": [
                {
                    "self": "http://localhost:3080/rest/api/2/customFieldOption/10019",
                    "value": "ABC-Custom 1",
                    "id": "10019"
                }
            ],
            "fixVersions": [

            ],
            "customfield_10011": [
                {
                    "self": "http://localhost:3080/rest/api/2/customFieldOption/10021",
                    "value": "ABC-Custom 2",
                    "id": "10021"
                }
            ],
            .....
            ....
            ....
        }
    }

1 个答案:

答案 0 :(得分:1)

您可以使用以下语法获取自定义字段的值:

fields.find { it.id == "customfield_10010" }.value

我有同样的问题,在这里找到了这个解决方案: https://issues.jenkins-ci.org/browse/JENKINS-13216