Groovy:Jenkinsfile:无法将带有空格的参数传递给 jenkins 管道中的 shell 脚本

发布于 2025-01-17 16:23:23 字数 593 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人间☆小暴躁 2025-01-24 16:23:23

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\"

您必须在常规字符串中用另一个反斜杠转义每个反斜杠

sh '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

sh 'detect.sh --detect.project.name=\\"Project Test\\"'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文