[英]Set environment variables from shell script in jenkins
I am trying to automate my build using Jenkins
. 我正在尝试使用
Jenkins
自动化构建。 My build process needs to execute three different shell scripts
. 我的构建过程需要执行三个不同的
shell scripts
。 The first script sets some environment variables
which is used by the second and the third scripts. 第一个脚本设置一些
environment variables
,第二个和第三个脚本使用这些environment variables
。 I am trying with a pipeline
job in Jenkins where each script is executed stage by stage. 我正在詹金斯(Jenkins)中尝试
pipeline
作业,其中每个脚本都逐步执行。 However I am unable to get the environment variables from the first script to the next one. 但是,我无法从第一个脚本到下一个脚本获取环境变量。
NB: There is a set of variables that are being set.So I don't feel like using a simple variable will do. 注意:有一组变量正在设置,所以我不觉得使用简单的变量就能做到。
Please help 请帮忙
You are probably confusing declarative pipeline with scripted pipeline 您可能会将声明性管道与脚本化管道混淆
Jenkinsfile (Declarative Pipeline) Jenkinsfile(声明性管道)
pipeline {
agent any
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
sh 'printenv'
}
}
}
}
Jenkinsfile (Scripted Pipeline) Jenkinsfile(脚本管道)
node {
withEnv(['DISABLE_AUTH=true',
'DB_ENGINE=sqlite']) {
stage('Build') {
sh 'printenv'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.