Skip to content

Instantly share code, notes, and snippets.

@bootswithdefer
bootswithdefer / vault.groovy
Created November 7, 2018 22:47
Using Hashicorp Vault AppRoles in a Jenkinsfile in pure groovy.
stage('pure-groovy-vault') {
agent none
environment {
VAULT_TOKEN_GEN_CRED = credentials('jenkins-vault-approle')
}
steps {
script {
println("Vault: Authenticate as Jenkins")
def body = """{"role_id": "${VAULT_TOKEN_GEN_CRED_USR}", "secret_id": "${VAULT_TOKEN_GEN_CRED_PSW}"}"""
def url = 'https://vault-url/v1/auth/approle/login'