Using environment variables
https://www.jenkins.io/doc/pipeline/tour/environment/
pipeline { agent { label '!windows' } environment { DISABLE_AUTH = 'true' DB_ENGINE = 'sqlite' } stages { stage('Build') { steps { echo "Database engine is ${DB_ENGINE}" echo "DISABLE_AUTH is ${DISABLE_AUTH}" sh 'printenv' } } } }
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
pipeline { agent any stages { stage('Example') { steps { echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}" } } } }
pipeline { agent any environment { CC = 'clang' } stages { stage('Example') { environment { DEBUG_FLAGS = '-g' } steps { sh 'printenv' } } } }
pipeline { agent any environment { // Using returnStdout CC = """${sh( returnStdout: true, script: 'echo "clang"' )}""" // Using returnStatus EXIT_STATUS = """${sh( returnStatus: true, script: 'exit 1' )}""" } stages { stage('Example') { environment { DEBUG_FLAGS = '-g' } steps { sh 'printenv' } } } }
https://www.jenkins.io/doc/pipeline/steps/credentials-binding/
pipeline { agent { // Define agent details here } environment { AWS_ACCESS_KEY_ID = credentials('jenkins-aws-secret-key-id') AWS_SECRET_ACCESS_KEY = credentials('jenkins-aws-secret-access-key') } stages { stage('Example stage 1') { steps { // } } stage('Example stage 2') { steps { // } } } }
标签:pipeline,agent,environment,steps,evironment,jenkins,stage From: https://www.cnblogs.com/lightsong/p/18502967