Skip to content

Instantly share code, notes, and snippets.

@tbeyer567
Created June 22, 2022 22:10
Show Gist options
  • Save tbeyer567/3a5fb9e1916c4afb0cb4fb8aba17dad8 to your computer and use it in GitHub Desktop.
Save tbeyer567/3a5fb9e1916c4afb0cb4fb8aba17dad8 to your computer and use it in GitHub Desktop.
def secrets = [
[path: 'secret/jenkins/github', engineVersion: 2, secretValues: [
[envVar: 'PRIVATE_TOKEN', vaultKey: 'private-token'],
[envVar: 'PUBLIC_TOKEN', vaultKey: 'public-token'],
[envVar: 'API_KEY', vaultKey: 'api-key']]],
]
def configuration = [vaultUrl: 'http://my-vault.com:8200', vaultCredentialId: 'vault-approle', engineVersion: 2]
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
disableConcurrentBuilds()
}
stages{
stage('Vault') {
steps {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh "echo ${env.PRIVATE_TOKEN}"
sh "echo ${env.PUBLIC_TOKEN}"
sh "echo ${env.API_KEY}"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment