相关疑难解决方法(0)

从Jenkins管道中的Groovy变量创建JSON字符串

我必须在Groovy中创建这个JSON文件.我尝试了很多东西(JsonOutput.toJson()/ JsonSlurper.parseText())但没有成功.

{
   "attachments":[
      {
         "fallback":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>",
         "pretext":"New open task [Urgent]: <http://url_to_task|Test out Slack message attachments>",
         "color":"#D00000",
         "fields":[
            {
               "title":"Notes",
               "value":"This is much easier than I thought it would be.",
               "short":false
            }
         ]
      }
   ]
}
Run Code Online (Sandbox Code Playgroud)

这是为了向Slack发布Jenkins构建消息.

groovy json jenkins jenkins-pipeline

17
推荐指数
2
解决办法
5万
查看次数

标签 统计

groovy ×1

jenkins ×1

jenkins-pipeline ×1

json ×1