I have issues with my block code - "withCredentials([usernamePassword(…it doesn’t recognize the usernameVariable and also the passwordVariable when I am using double quotes.
example jenkinsfile:
parameters {
credentials(name: 'APP_CREDS', defaultValue: 'APP_CREDS', credentialType: "Username with password", required: true, description: "Credentials")
}
withCredentials([usernamePassword(credentialsId: 'APP_CREDS', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
env.APP_USER = "${USERNAME}"
env.APP_PASSWORD = "${PASSWORD}"
}
Example error output:
Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 4d5b57c6-d3f9-4317-9a23-43cccd3a834e
groovy.lang.MissingPropertyException: No such property: USERNAME for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:285)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355)
at