How Do You Verify the Jenkins Credentials Plugin Username and Password Are Correct and in the Right Syntax?

Problem Scenario
You are using Jenkins and its Credentials plugin. You are not sure if the syntax of the username and password are correct. You think that there may be a wrong username or password. You want to see how things look as they are used in a pipeline job. The console output shows the credentials as "****". What should you do?

Warning: this is not a recommended practice. The console output of a job will show the credentials in clear text.

#1 Configure a pipeline job to echo the credentials to a file (e.g., /tmp/sensitive). There is syntax in a Jenkins pipeline to invoke raw shell commands: sh 'echo $userpasscombo > /tmp/sensitive'

#2 Run the above pipeline.

#3 Change the pipeline in two ways. First remove the "withCredentials" syntax that allows you to get the username and password from the credentials plugin. Secondly configure a pipeline job to echo the /tmp/sensitive file.

#4 Run the above pipeline (from step #3). Look at the console output. You will see the credentials in plain text.

Leave a comment

Your email address will not be published. Required fields are marked *