我在管道语法中声明了环境变量,并试图通过从工作区读取文件来为变量赋值。赋值不反映在环境变量中。我的配置如下所示
pipeline {
agent any
environment {
test = ''
}
stages {
stage('Test') {
script {
writeFile(file: 'hello.txt', text: "hello world")
env.test = readFile(file: 'hello.txt')
echo 'test:'"${env.test}" // coming as null
}
}
}
}
}发布于 2021-12-08 19:30:50
尝试从环境块中删除test。
此外,在显示''和""时,您遇到了问题,请尝试这样做:
echo "test: ${env.test}" // coming as nullhttps://stackoverflow.com/questions/70279616
复制相似问题