我有一个jenkins管道,它构建一个使用powershell来创建基于json的请求的作业。当我通过管道运行作业时,我的脚本在整个json中添加了各种换行符。当我通过点击“重建”来完成工作时脚本运行没有问题。
通过jenkins管道输出我的请求:
pip install pymongo
通过' rebuild'输出我的请求或手动:
Invoke-RestMethod -Uri http://api.newrelic.com/v2/applications/17303495/deployments.json -Method 'POST' -Headers System.Collections.Hashtable -ContentType 'application/json' -Body {
"deployment": {
"revision": "Deployment of e0ca4b7
",
"changelog": "See Release Email Notes",
"description": "Beginning Deployment of e0ca4b7
",
"user": "pcort"
}
}
帮助!这真的很奇怪,破坏了我的代码:)任何想法都会很棒!
Jenkins正在运行ver。 2.46.2并且所有插件都是最新的。
答案 0 :(得分:1)
问题在于获取构建标签。我不完全确定它是如何工作的,也许有更多知识的人可以告诉我,但是获得短git commit git rev-parse --short HEAD
是在变量的末尾留下一个空格或换行符(我通过电源外壳)。通过添加.trim()我清除了它。