Page History
In Jenkins is it possible to store the Blueriq Studio username and password credentials as a Secret. With the Credentials Binding Plugin u are able to configure a Secret, such as a username and password and map it to and specific credentials id. These credentials are then store on the master Jenkins instance, which are encrypted by the Jenkins instance ID. If you want to know more about configuring credentials in Jenkins read the using credentials page.
Using the Secret inside a Jenkins Pipeline Script
For this example we have created a Secret in Jenkins with the name 'studio-credentials'. In order to use the credentials binding plugin you will need to specify a withCredentials
inside your pipeline script. The plugin will automatically redact every referral to the username and password credentials.
Code Block | ||||
---|---|---|---|---|
| ||||
withCredentials([usernamePassword(credentialsId: 'studio-credentials', usernameVariable: 'studio-user', passwordVariable: 'studio-password')]) {
// available as an env variable, but will be masked if you try to print it out any which way
// note: single quotes prevent Groovy interpolation; expansion is by Bourne Shell, which is what you want
bat "C:\model-mapper\cli-test-runner-win.exe --proxyServerUrl=http://localhost:1337 --studioUsername=${studio-user} --studioPassword=${studio-password} --repository=MyRepository --branch=Trunk --project=MyProject"
}
|
Running this particular script will result in the following output. As you can see content of the studio-user and studio-password variable is replaced by '****'.
Code Block | ||||
---|---|---|---|---|
| ||||
[Pipeline] {
[Pipeline] withCredentials
[Pipeline] {
[Pipeline] bat
C:\jenkins\workspace\test-cli-runner>C:\model-mapper\cli-test-runner-win.exe --proxyServerUrl=http://localhost:1337 --studioUsername=**** --studioPassword=**** --repository=MyRepository --branch=Trunk --project=MyProject
Successfully logged in
Created project export for project 'MyProject'.
Retrieving all data mapping test cases from workspace.
Found '1' data mapping test cases in workspace.
Retrieving data mapping 'fwd_DataMapping' from Studio.
Retrieving meta models from Studio.
Executing test 'Test' for data mapping 'fwd_DataMapping' in module 'configuration'.
Test 'Test': Succeeded
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] } |
More information about how to inject Secrets into Jenkins Build Jobs can be found here.