更新时间:2022-11-18 22:04:12
env.BUILD_ID
是一个常规变量,而不是shell变量.由于您使用了单引号('
),因此groovy将 not 替换为字符串中的变量,并且shell不了解${env.BUILD_ID}
.您需要使用双引号"
并让groovy进行替换
env.BUILD_ID
is a groovy variable, not a shell variable. Since you used single-quotes ('
) groovy will not substitute the variables in your string and the shell doesn't know about ${env.BUILD_ID}
. You need to either use double-quotes "
and let groovy do the substitution
sh "echo version := 1.0.${env.BUILD_ID} >> build.sbt"
或使用外壳程序知道的变量
or use the variable the shell knows
sh 'echo version := 1.0.$BUILD_ID >> build.sbt'
并且由于您需要用双引号引起来的版本,因此需要这样的内容:
and since you need the version surrounded with doublequotes, you'd need something like this:
sh "echo version := \\\"1.0.${env.BUILD_ID}\\\" >> build.sbt"