Last active
October 30, 2020 18:46
-
-
Save abuxton/98c7b3e9ceddc6385c8d80059b4d7f20 to your computer and use it in GitHub Desktop.
jenkins minimal curl Gist
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 | |
stages { | |
stage('Integration Tests') { | |
steps { | |
script { | |
def ROLE_ID = "REPLACE_WITH_ID" | |
def SECRET_ID = "REPLACE_WITH_ID" | |
/* sh ''' | |
set +x | |
curl -k \ | |
--request POST \ | |
--data '{"role_id":"ROLE_ID","secret_id":"SECRET_ID"}' \ | |
--header 'X-Vault-Namespace:NAMESPACE' \ | |
https://VAULT_ADDR:8200/v1/auth/approle/login | |
''' | |
*/ | |
def requestBody = """{"role_id": "${ROLE_ID}", "secret_id": "${SECRET_ID}"}""" | |
def response = httpRequest(ignoreSslErrors: true, | |
customHeaders: [[name: 'x-vault-namespace', value:'NAMESPACE']], | |
httpMode: 'POST', | |
requestBody: requestBody, | |
url: 'https://VAULT_ADDR/v1/auth/approle/login' ) | |
println(response.content) | |
def jsonObj = readJSON(text: response.content) | |
println(jsonObj.auth.client_token) | |
def secretResponse = httpRequest(ignoreSslErrors: true, | |
customHeaders: [[name: 'x-vault-namespace', value:'NAMESPACE'], [name:'x-vault-token', value: jsonObj.auth.client_token]], | |
httpMode: 'GET', | |
url: 'https://VAULT_ADDR:8200/v1/kv/data/kv/secret' ) | |
println(secretResponse.content) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sh """
set +x
curl -k
--request POST
--data '{"role_id":"${ROLE_ID}","secret_id":"${SECRET_ID}"}'
--header 'X-Vault-Namespace:NAMESPACE'
https://VAULT_ADDR:8200/v1/auth/approle/login
"""