jenkins内置变量
pipeline {
agent any
stages {
stage('Example') {
steps {
echo "Running ${env.BUILD_NUMBER} on ${env.JENKINS_URL}" // Method 1
echo "Running $env.BUILD_NUMBER on $env.JENKINS_URL ${env.BRANCH_NAM}" // Method 2
echo "Running ${BUILD_NUMBER} on ${JENKINS_URL}" // Method 3 这种方法不推荐
}
}
}
}
自定义pipeline环境变量
pipeline {
agent any
environment {
__cc = 'clang'
}
stages {
stage('Example') {
environment {
__DEBUG_FLAGS = '-g'
}
steps {
sh "${__cc} ${__DEBUG_FLAGS}"
sh 'printenv'