I have a query regarding Jenkins secret text. I am trying to load stored azure cli json credentials from Jenkins secret text credentials. Can someone guide me how to achieve that .
Consider I have in this format {
“username”: “your-azure-username”,
“password”: “your-azure-password”,
“tenantId”: “your-azure-tenant-id”
}
Thanks
Not sure what you meant but this allows read the json and use it
Beware that direct usage of the password from the json as below is dangerous as the password will not be masked. So you might want to wrap the usage in a maskPasswords
step
withCredentials([string(credentialsId: 'json-secret-text', variable: 'AZURE_SECRET')]) {
s = readJSON text: AZURE_SECRET
echo s.tenantId
echo s.password
maskPasswords(varPasswordPairs: [[password: s.password, var: ''], [password: s.tenantId, var: '']]) {
echo s.password
echo s.tenantId
}
}