Secret text in Jenkinsfile scripted pipelines
Scripted pipelines are great for using Jenkinsfile but Jenkins’ documentation doesn’t tell how to use credentials with them. And trying to use the credentials function listed there won’t work.
In short, this is what does work:
First setup your secret text in the Credentials category like so (if you don’t have the credentials category make sure you have the Credentials plugin installed and enabled):
Open the credentials category:
Add new credentials:
Enter the info and confirm:
- Then in your Jenkinsfile use the following:
1 | node { |
Output:
My password is '****'