Allows various kinds of credentials (secrets) to be used in idiosyncratic ways. Each binding will define an environment variable active within the scope of the step. You can then use them directly from any other steps that expect environment variables to be set:
node {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'mylogin',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
set +x
curl -u $USERNAME:$PASSWORD https://private.server/ > output
'''
}
}
or retrieve values from Groovy code via the env
magic variable:
def password = env.PASSWORD
Note that some steps explicitly ask for credentials of a particular kind,
usually as a credentialsId
parameter,
in which case this step is unnecessary.