How to Hide Password from Jenkins Shell Output

How to hide passwords in Jenkins console output?

Tested with Jenkins 1.609.1 and Mask Passwords Plugin 2.7.3. You need to activate it in the "Configure System" and also in the job you want to use this. In the job configuration is a point "Mask passwords" which must be activated and then will use the global config to mask passwords.

Hiding passwords in Jenkins Pipeline log output without using WithCredentials

I think you are looking for JENKINS-36007?

Hiding password in Jenkins pipeline script

The simplest way would be to use the Credentials Plugin.

There you can define different types of credential, whether it's a single password ("secret text"), or a file, or a username/password combination. Plus other plugins can contribute other types of credentials.

When you create a credential (via the Credentials link on the main Jenkins page), make sure you set an "ID". In the example below, I've called it my-pass. If you don't set it, it will still work, Jenkins will allocate an opaque UUID for you instead.

In any case, you can easily generate the required syntax with the snippet generator.

withCredentials([string(credentialsId: 'my-pass', variable: 'PW1')]) {
echo "My password is '${PW1}'!"
}

This will make the password available in the given variable only within this block. If you attempt to print the password, like I do here, it will be masked.

How to hide password from jenkins shell output

The Mask Passwords plugin does just that.

JENKINS - GROOVY - PIPELINE: How to hide a password from logs when the password is retrieved during the build itself

In the groovy file, i did put

  • set +x
  • get the password from the vault
  • echo the default in a netrc file
  • echo the password in the same netrc file
  • echo the username in the same netrc file
  • set -x
  • and curl with the netrc file

so i can debug



Related Topics



Leave a reply



Submit