Unable to see Jenkins Credentials values
Write the variable to a file in jenkins. Go to the jenkins workspace and look inside the file. The token will be present in plain text there.
UPDATE
Further easy way will be to print the base64
encoded value of the credential and then decode it.
Like the others added above, you could actually write it to a file and then cat the file outside of the withCredentials. You should be fine with this. As below..
withCredentials([usernamePassword(credentialsId: 'creds-test', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { sh ''' echo $USERNAME > tmp echo $PASSWORD >> tmp ''' } sh 'cat tmp'
This prints the actual credential values
Consider manipulating the string
echo env.PASSWORD.toCharArray().join(' ');
like
stages { stage('Build') { steps { withCredentials([usernamePassword(credentialsId: 'creds-test', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME')]) { script { echo env.USERNAME.toCharArray().join(' '); echo env.PASSWORD.toCharArray().join(' '); } sh ''' chmod +x secrets-replace.sh ./secrets-replace.sh USERNAME_PLACEHOLDER $USERNAME ./secrets-replace.sh PASSWORD_PLACEHOLDER $PASSWORD ''' } echo 'Building...' sh './gradlew build --refresh-dependencies' } } ...}