天啊,这能有多难....试图重命名磁盘上的文件。
stage('upload binaries')
{
steps
{
dir ("firmware")
{
script {
version = readFile("app/source/version.txt")
}
script {
newfilename = "app/build-app/app${version}.bin"
}
echo "hello....!"
echo "$version"
echo "$newfilename"
sh "mv app/build-app/app.bin app/build-app/app$version.bin"
upload_bin_file($newfilename)
}
}
}
输出此
Running in /var/jenkins_home/workspace/y_feature_upload-labelled-binary/firmware
[Pipeline] {
[Pipeline] script
[Pipeline] {
[Pipeline] readFile
[Pipeline] }
[Pipeline] // script
[Pipeline] script
[Pipeline] {
[Pipeline] }
[Pipeline] // script
[Pipeline] echo
hello....!
[Pipeline] echo
v1.0.51
[Pipeline] echo
app/build-app/appv1.0.51
.bin
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
无论我尝试什么,它都不会附加“.bin”部分。
- 已尝试单/双配额
- 已尝试$var和${var}
- 已尝试$env.var和${env.var}
- 尝试转义应用程序${version}.bin中的“点”
阅读有关变量的页面https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
仍然不知道如何完成这个最琐碎的任务。
帮助?:)
1条答案
按热度按时间i34xakig1#
$version的值来自一个文件,所以我相信这个变量有一个换行符。
试着将其移除。