Created
October 4, 2019 05:11
-
-
Save lepffm/910d78fe1d8d2ae12c15de37ea96f88f to your computer and use it in GitHub Desktop.
jenkins read hashicorp vault pipeline example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent any | |
environment { | |
VAULT_TOKEN = 'YOUR_VAULT_TOKEN' | |
VAULT_API_ADDR = 'YOUR_VAULT_URL/v1' | |
} | |
stages { | |
stage("read vault"){ | |
steps { | |
script{ | |
txt = sh(returnStdout: true, script: "curl -s -H \"X-Vault-Token:$VAULT_TOKEN\" -X GET $VAULT_ADDR/your_secret_path/?list=true").trim() | |
json = new groovy.json.JsonSlurperClassic().parseText(txt) | |
json.data.keys.sort().each{ key -> | |
println "key=${key}" | |
txt = sh(returnStdout: true, script: "curl -s -H \"X-Vault-Token:$VAULT_TOKEN\" -X GET $VAULT_ADDR/your_secret_path/${key}").trim() | |
json = new groovy.json.JsonSlurperClassic().parseText(txt) | |
json.data.each{ entry -> | |
println entry.key + " = " + entry.value | |
} | |
} | |
}//script | |
}//steps | |
} | |
}//stages | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment