Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

104 lines (94 sloc) 2.83 KB
// docs: https://jenkins.io/doc/pipeline/steps/credentials-binding/
pipeline {
agent any
stages {
stage('usernamePassword') {
steps {
script {
withCredentials([
usernamePassword(credentialsId: 'gitlab',
usernameVariable: 'username',
passwordVariable: 'password')
]) {
print 'username=' + username + 'password=' + password
print 'username.collect { it }=' + username.collect { it }
print 'password.collect { it }=' + password.collect { it }
}
}
}
}
stage('usernameColonPassword') {
steps {
script {
withCredentials([
usernameColonPassword(
credentialsId: 'gitlab',
variable: 'userpass')
]) {
print 'userpass=' + userpass
print 'userpass.collect { it }=' + userpass.collect { it }
}
}
}
}
stage('string (secret text)') {
steps {
script {
withCredentials([
string(
credentialsId: 'joke-of-the-day',
variable: 'joke')
]) {
print 'joke=' + joke
print 'joke.collect { it }=' + joke.collect { it }
}
}
}
}
stage('sshUserPrivateKey') {
steps {
script {
withCredentials([
sshUserPrivateKey(
credentialsId: 'production-bastion',
keyFileVariable: 'keyFile',
passphraseVariable: 'passphrase',
usernameVariable: 'username')
]) {
print 'keyFile=' + keyFile
print 'passphrase=' + passphrase
print 'username=' + username
print 'keyFile.collect { it }=' + keyFile.collect { it }
print 'passphrase.collect { it }=' + passphrase.collect { it }
print 'username.collect { it }=' + username.collect { it }
print 'keyFileContent=' + readFile(keyFile)
}
}
}
}
stage('dockerCert') {
steps {
script {
withCredentials([
dockerCert(
credentialsId: 'production-docker-ee-certificate',
variable: 'DOCKER_CERT_PATH')
]) {
print 'DOCKER_CERT_PATH=' + DOCKER_CERT_PATH
print 'DOCKER_CERT_PATH.collect { it }=' + DOCKER_CERT_PATH.collect { it }
print 'DOCKER_CERT_PATH/ca.pem=' + readFile("$DOCKER_CERT_PATH/ca.pem")
print 'DOCKER_CERT_PATH/cert.pem=' + readFile("$DOCKER_CERT_PATH/cert.pem")
print 'DOCKER_CERT_PATH/key.pem=' + readFile("$DOCKER_CERT_PATH/key.pem")
}
}
}
}
stage('list credentials ids') {
steps {
script {
sh 'cat $JENKINS_HOME/credentials.xml | grep "<id>"'
}
}
}
}
}
You can’t perform that action at this time.