Jenkins Configurations
Specify Git Branch Code
Global Pipeline Libraries
@Library('name_of_library') _Manifests
Credentials
Last updated
@Library('name_of_library') _Last updated
// You need the Credential and Credential Binding plugins
withCredentials([
usernamePassword( // function that gives the username and password individually
credentials: "<global_credential_ID>",
usernameVariable: "USER", // stores username into USER variable
passwordVariable: "PWD" // stores password into PWD variable
)
]) {
// So here, we can use USER and PWD
sh "some script ${USER} ${PWD}"
}
// Alternatively we can do this too:
withCredentials([
usernameColonPassword( // function that gives the username and password in this form -> <username>:<password>
credentials: "<global_credential_ID>",
variable: "CREDS"
)
]) {
// useful for curl which takes the username and password in the colon form
sh "curl -u ${CREDS} -X GET 'some_url >> some_json.json'"
}