Skip to content

Instantly share code, notes, and snippets.



Created Oct 5, 2017
What would you like to do?
Declarative Jenkinsfile Environment Variables
pipeline {
agent any
stages {
stage('Example') {
environment {
// 'This value is exported to all commands in this stage'
AWESOME_BUILD = "${env.BUILD_ID + '/working'}"
steps {
sh 'mkdir -p $AWESOME_BUILD'
sh 'touch $AWESOME_BUILD/the_file'
// Try to export the variable
sh 'export AWESOME_FILE=$AWESOME_BUILD/the_file'
// But it won't show up here!
sh 'echo $AWESOME_FILE'
// However, if we bundle it in a single sh command
// it will work.
sh '''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.