79197272

Date: 2024-11-17 13:22:13
Score: 1
Natty:
Report link

Apply usernamePassword(credentialsId: env.CREDENTIALS, .. ) to provide selected credential to the script as custom variables, example:

steps {
    withCredentials([ usernamePassword(
            credentialsId: env.CREDENTIALS,
            usernameVariable: 'USERNAME',
            passwordVariable: 'PASSWORD') ]) {
        script {
            sh( script: "./my_shell_script.sh" )   // echo "$USERNAME, $PASSWORD"
        }
    }
}

.. see my detailed answer to a similar question: https://stackoverflow.com/a/79197253/1745341

Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Alex