我正在尝试使用Jenkins
自动进行构建。我的构建过程需要执行三个不同的shell scripts
。第一个脚本设置 some environment variables
,第二个和第三个脚本会使用。
我正在詹金斯(Jenkins)从事一项pipeline
工作,其中每个脚本都被逐步执行。但是,我无法从第一个脚本到下一个脚本获取环境变量。
注意:正在设置一组变量。因此,我不认为使用简单变量即可。
请帮助
答案 0 :(得分:0)
您可能会混淆declarative pipeline with scripted pipeline
Jenkinsfile(声明性管道)
pipeline {
agent any
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
sh 'printenv'
}
}
}
}
Jenkinsfile(脚本化管道)
node {
withEnv(['DISABLE_AUTH=true',
'DB_ENGINE=sqlite']) {
stage('Build') {
sh 'printenv'
}
}
}