I\'ve stored username and password as credentials in jenkins. Now I would like to use them in my Jenkinsfile.
I am using withCredentials
DSL, however, I\'m
You can use the UsernamePasswordMultiBinding
to get credential data in separate values:
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'mycreds',
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']
])
So the following should work in your case:
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'mycreds', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh 'cf login some.awesome.url -u $USERNAME -p $PASSWORD'
}