加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – Jenkins文本参数 – 特殊字符乱码(不需要的变量替换)

发布时间:2020-12-16 01:58:24 所属栏目:安全 来源:网络整理
导读:我在Jenkins(在 Linux下)有一个工作,build parameter类型为“Text”.我使用参数来形成在构建过程中使用的文件的内容,使用bash“shell execute”步骤,如echo“$TEXTPARAM”文件. 如果有一般文本,它的效果很好.但是当出现像“$”这样的字符时 – 它表现得很奇
我在Jenkins(在 Linux下)有一个工作,build parameter类型为“Text”.我使用参数来形成在构建过程中使用的文件的内容,使用bash“shell execute”步骤,如echo“$TEXTPARAM”>文件.

如果有一般文本,它的效果很好.但是当出现像“$”这样的字符时 – 它表现得很奇怪.

E. g.文本

Some $one and $$two and $$$more bucks and $bucks $$that $$$stand alone and$after$$words$$$

变成了

Some $one and $two and $-sl bucks and $bucks $that $$stand alone and$after$words$$

虽然我希望文本出现在文件中,就像它出现在输入文本框中一样.

这是jenkins的一个错误(所以我应该向他们的跟踪器发布一个问题)或者我做错了什么?

UPDATE
我想这是由于Jenkins完成的变量替换.即,在执行任何“shell执行”步骤之前,所有$VARNAME都被VARNAME值替换.而现在替换cannot be turned off.

解决方法

根据这张票 https://issues.jenkins-ci.org/browse/JENKINS-16143的评论

This appears to not be a bug. Compare the parameter values $JENKINS_URL and $$JENKINS_URL.
Jenkins internally resolves placeholders in variables,
and dollars are used for that. $$is an escaped $.

我在Jenkins ver上观察字符串和文本字段的相同行为. 1.562

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读