Created
October 5, 2017 02:45
-
-
Save 23jodys/622c13bcf0fc3d299761f84cf7b37364 to your computer and use it in GitHub Desktop.
Declarative Jenkinsfile Environment Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ''' | |
export AWESOME_FILE=$AWESOME_BUILD/the_file | |
echo $AWESOME_FILE | |
''' | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment