Jenkins : withCredentials does not mask passwords in Groovy Script
I am using Credentials and CredentialBinding to mask credentials passed to "bat" to be used in "net use" to connect to a share via a groovy script. Unfortunately the password is exposed in console log :
withCredentials([
usernamePassword(
credentialsId: credentialsId,
passwordVariable: 'PASSWORD',
usernameVariable: 'USER'
)
]) {
def user = this.env['USER'];
def password = this.env['PASSWORD'];
bat "net use \\\\$server $PASSWORD /user:$user /persistent:yes"
bat "net use"
}
I tried using %PASSWORD% in single quotes as well , but strings are not getting interpolated in "net use". Please let me know if something is amiss.