Jenkins 2.107.3
我有一个管道詹金斯工作来执行下面的脚本,运行npm run
脚本
{
"name": "jenkins-postman-automation",
"version": "1.0.0",
"description": "test project",
"directories": {
"test": "01-TNR-CLIMPLUS-NEWMAN"
},
"scripts": {
"api-tests": "newman run 01-TNR-NEWMAN/01-TNR-CORE.postman_collection.json -e 99-Environnements/${Environnement} "
},
"author": "Reda",
"dependencies": {
"newman": "^3.5.2"
}
}
管道:
node(){
stage("testing"){
deleteDir()
echo 'git clone'
git branch: 'master', url: '[email protected]/postman.git'
sh "npm install"
try {
sh "npm run api-tests"
} catch (Exception err) {
currentBuild.result = 'UNSTABLE'
}
}
}
${Environnement}
时${Environnement}
中声明def Environnement = "DEV"
时出现以下错误:unable to read data from file "-e" ENOENT: no such file or directory, open '-e'
仅在使用声明性管道时有效,但现在不起作用。
将def Environnement = "DEV"
更改为env.Environnement="DEV"
。 env.xxx会将值设置为shell上下文的环境变量,因此npm run api-tests
可以从shell上下文获取该值。