# run jenkins/jenkins:lts, with volumes, exposed ports
docker run -d -v jenkins_home:/var/jenkins_home \
-p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
# Jenkins Pipeline script, using Credentials
pipeline {
agent any
parameters {
credentials(
name: 'param_secret',
description: 'Build parameter secret.',
defaultValue: 'default_value',
credentialType: 'Build parameter secret.',
required: true
)
}
environment {
ENV_SECRET = credentials('global_secret')
}
stages {
stage('Param Secret') {
steps {
echo "param_secret = ${params.param_secret}"
}
}
stage('Global Secret') {
steps {
echo "env_secret = $ENV_SECRET"
}
}
stage('Stage Secret') {
environment {
STAGE_SECRET = credentials('global_secret')
}
steps {
echo "stage_secret = $STAGE_SECRET"
}
}
}
}
https://jenkins.io/doc/book/pipeline/jenkinsfile/#handling-credentials
https://jenkins.io/doc/pipeline/steps/credentials-binding/