Encapsulate API User Credentials in Job-Specific Configuration
Currently, we do not support using API credentials provided in Global Configuration to be used as it is in a Job Specific Configuration, without the need to specify the credentials for each Job Specific configuration.
However, you can create variables to encapsulate the user credentials and then use the variables instead of actual user credentials while creating a Job Specific Configuration.
To create variables to encapsulate, perform the following steps on the Pipeline Syntax > Snippet Generator page:
- Select 'withCredentials: Bind credentials to variables'. Under Bindings.
- Click Add and then select 'Username and password (separated)'.
- Specify variable names for Username and Password.
- Select the appropriate credentials, and then click Generate Pipeline Script.
Sample Script
withCredentials([
usernamePassword("credentialsId":"xxxxx",
"passwordVariable":"PASS",
"usernameVariable":"USER"")"
]")"{
}
Now, generate your Job Specific Configuration by providing the variables in place of the username and password.
Sample script withUsername and Password
"getImageVulnsFromQualys apiPass":"PASS",
"apiServer":"<qualys_base_url>",
"apiUser":"USER",
"imageIds":"env.IMAGE_ID",
"isSev4Vulns":true,
"isSev5Vulns":true,
"pollingInterval":"30",
"proxyPort":3128,
"proxyServer":"10.115.27.54",
"useLocalConfig":true,
"useProxy":true,
"vulnsTimeout":"600""Place the Job Specific Configuration script in the""WithCredentials""block":"withCredentials("[
"usernamePassword(credentialsId":"xxxxx",
"passwordVariable":"PASS",
"usernameVariable":"USER"")"
]")"{
"getImageVulnsFromQualys apiPass":"PASS",
"apiServer":"<>",
"apiUser":"USERQual",
"imageIds":"env.IMAGE_ID",
"isSev4Vulns":true,
"isSev5Vulns":true,
"pollingInterval":"30",
"proxyPort":3128,
"proxyServer":"10.115.27.54",
"useLocalConfig":true,
"useProxy":true,
"vulnsTimeout":"600"
}