This article shows you how to inject credentials into a builder template.
1. Create a credential with the username/password option.

2. Create a builder template
New Item->Builder Template
Now, let’s create an attribute:

After this, I configured the transformer as following:

3. Create free style job using this build template
New Item->Freestyle project
Then, in the build section you need to add the build-template you have created as a build step.

4. Finally build and you should get an output like this one:
Started by user admin Building in workspace /Users/Felix/CloudBees/jenkins-test/1.580.2.1/jenkins\_home/jobs/builder-job/workspace \[workspace\] $ /bin/sh -e /var/folders/pb/jd1lfm8x2f91s0htlm2zvsmh0000gn/T/hudson8819317042280542346.sh credential: myusername2/mypassword2 Finished: SUCCESS
Groovy Script:
zeUserName = mycredential.username zePassword = mycredential.password
Shell Script:
echo "credential: $zeUserName/$zePassword"
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.