--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/Y4ROJK3SmJsTTxhz%40vrs6.4vrs.com.
Have you tested your suggestion?
For me,
SERVICE_KEY_S =
credentials(env.BRANCH_NAME == 'STAGE-NOV28' ? 'SERVICE_KEY' :
'PROD_SERVICE_KEY')
thows the error:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
WorkflowScript: 40: Internal function call parameters must be
strings. @ line 40, column 32.
SERVICE_KEY_S = credentials(env.BRANCH_NAME ==
'STAGE-NOV28' ? 'SERVICE_KEY' : 'PROD_SERVICE_KEY')
I have also tried this syntax (found in the Internet somewhere):
MYTESTVAR = "${env.BRANCH_NAME == "main" ?
"credentials('PROD_SERVICE_KEY')" :
"credentials('SERVICE_KEY')"}"
and it does not work either. Maybe the issue is with single or
double quotes. Anyway, a real-life working example is very
welcome.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPzq3pemjoPXo%3DcCeC9oEwdNhD88VqXM6BvBRbZUsQoba172jw%40mail.gmail.com.
This syntax may be operational, but I need more testing:
environment {
SERVICE_KEY = credentials("${env.BRANCH_NAME == 'master' ? 'PROD_SERVICE_KEY' : 'SERVICE_KEY'}")
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/01f47251-a69e-039c-68c2-7377f902768e%404vrs.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4ea64a90-9347-48d6-b4e7-cfc013bc659a%404vrs.com.
Hello Arnaud,
Can you please post the whole line within environment{} as you suggest it should look?
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_CMo%3D7nYQjWOo_H-75LfLTH9Dq2MzJfsEZ4w1SuZpNdZA%40mail.gmail.com.
environment {
SERVICE_KEY = credentials("${env.BRANCH_NAME.equals('master') ? 'PROD_SERVICE_KEY' : 'SERVICE_KEY'}")
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5a24d450-e8c0-8f22-4c34-03031f81444e%404vrs.com.
What would you do if you needed multiple branches with multiple
choices of variables, like a "case" or "if ... else ... elif"
operators?
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_A3DKVfm1S56EUbSYwNa4p5_GQOQX%3D_SMNXuwoFb4sO0w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3a177946-c087-552e-413d-6220f1caedf9%404vrs.com.