Groovy:Jenkinsfile:无法将带有空格的参数传递给 jenkins 管道中的 shell 脚本
我在 jenkins 文件中使用脚本,并且传递的参数之一包含空格 (--detect.project.user.groups="DATABASE RELEASE 1.0"):
sh './detect.sh --logging.level.com.synopsys.integration=DEBUG --blackduck.url="${URL}" --blackduck.api.token="${TOKEN}" --detect.project.version.name=${buildVersion} --detect.project.user.groups=\"DATABASE RELEASE 1.0\" --detect.project.name=${projectName} --detect.source.path="${artifact_dir}/"'
通过常规 shell 脚本触发时相同的脚本工作正常,blackduck 是能够选取包含空格的用户组,但使用 sh 在脚本内的 jenkinsfile 中运行相同的命令,这里仅选取 DATABASE
并且扫描失败,因为它无法找到正确的用户组。
让我知道是否有任何解决办法。
谢谢!
I am using a script in my jenkins file and one of the argument passed contains a space (--detect.project.user.groups="DATABASE RELEASE 1.0"):
sh './detect.sh --logging.level.com.synopsys.integration=DEBUG --blackduck.url="${URL}" --blackduck.api.token="${TOKEN}" --detect.project.version.name=${buildVersion} --detect.project.user.groups=\"DATABASE RELEASE 1.0\" --detect.project.name=${projectName} --detect.source.path="${artifact_dir}/"'
The same script when triggered through regular shell script worked fine and blackduck was able to pick up the user group with the space included but the same command run through jenkinsfile inside scripts with sh, here only DATABASE
gets picked up and the scan fails as it is not able to find the correct userGroup.
Let me know if there is any fix to this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://community.synopsys.com/s/document-item?bundleId=integrations-detect&topicId=scripts%2Fscript-escaping-special-characters.html&_LANG=enus
具有文字 < code>detect.sh --detect.project.name=\"Project Test\"
您必须在常规字符串中用另一个反斜杠转义每个反斜杠
https://community.synopsys.com/s/document-item?bundleId=integrations-detect&topicId=scripts%2Fscript-escaping-special-characters.html&_LANG=enus
To have literal
detect.sh --detect.project.name=\"Project Test\"
You have to escape each backslash with another one in groovy string