Issue
I am trying to automate my build using Jenkins
. My build process needs to execute three different shell scripts
. The first script sets some environment variables
which is used by the second and the third scripts.
I am trying with a pipeline
job in Jenkins where each script is executed stage by stage. 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
Solution
You are probably confusing declarative pipeline with scripted pipeline
Jenkinsfile (Declarative Pipeline)
pipeline {
agent any
environment {
DISABLE_AUTH = 'true'
DB_ENGINE = 'sqlite'
}
stages {
stage('Build') {
steps {
sh 'printenv'
}
}
}
}
Jenkinsfile (Scripted Pipeline)
node {
withEnv(['DISABLE_AUTH=true',
'DB_ENGINE=sqlite']) {
stage('Build') {
sh 'printenv'
}
}
}
Answered By - Joao Vitorino
Answer Checked By - David Goodson (JavaFixing Volunteer)