environment {
SERVICE_KEY = credentials("${env.BRANCH_NAME.equals('master') ?
'PROD_SERVICE_KEY' : 'SERVICE_KEY'}")
Le ven. 2 déc. 2022, 03:05, Victor Sudakov <[email protected]> a écrit :
> Hello Arnaud,
>
> Can you please post the whole line within environment{} as you suggest it
> should look?
>
> On 02.12.2022 03:47, Arnaud bourree wrote:
>
> Hi,
>
> env.master'.equals(env.BRANCH_NAME) is String as 'master' is.
> Try 'master'.equals(env.BRANCH_NAME) instead of
> env.BRANCH_NAME == 'master'
>
> Le mer. 30 nov. 2022, 05:24, Victor Sudakov <[email protected]> a écrit :
>
>> This syntax may be operational, but I need more testing:
>>
>> environment {
>>
>> SERVICE_KEY = credentials("${env.BRANCH_NAME == 'master' ?
>> 'PROD_SERVICE_KEY' : 'SERVICE_KEY'}")
>>
>> }
>>
>>
>> On 30.11.2022 09:53, Victor Sudakov wrote:
>>
>> 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.
>> On 30.11.2022 06:36, James Nord wrote:
>>
>> Try
>>
>> credentials(env.BRANCH_NAME='main' ? 'PROD_CLIENT_ID' : 'DEV...')
>>
>> or some syntax like that..
>>
>> On Mon, 28 Nov 2022, 06:05 Victor Sudakov, <[email protected]> wrote:
>>
>>> Dear Colleagues,
>>>
>>> Can you please suggest a way to use different credentials depending on
>>> the Git
>>> branch in a multi-branch pipeline? In other words, I would like to have
>>>
>>> pipeline {
>>> environment {
>>> CLIENT_ID = credentials('PROD_CLIENT_ID')
>>> }
>>> ...
>>> }
>>>
>>> if the Git branch is "main" and
>>>
>>> pipeline {
>>> environment {
>>> CLIENT_ID = credentials('DEV_CLIENT_ID')
>>> }
>>> ...
>>> }
>>>
>>> if the Git branch is "dev", or even "*".
>>>
>>> What would be the correct Groovy syntax to substitute "PROD_CLIENT_ID" or
>>> "DEV_CLIENT_ID" depending on the branch name?
>>>
>>> --
>>> Victor Sudakov
>>> Systems Administrator
>>> Streamline - Property Management Software
>>> Website: www.streamlinevrs.com
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/Y4ROJK3SmJsTTxhz%40vrs6.4vrs.com
>>> .
>>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/CAPzq3pemjoPXo%3DcCeC9oEwdNhD88VqXM6BvBRbZUsQoba172jw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAPzq3pemjoPXo%3DcCeC9oEwdNhD88VqXM6BvBRbZUsQoba172jw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> Victor Sudakov
>> Systems Administrator
>> Streamline - Property Management Software
>> Website: www.streamlinevrs.com
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/01f47251-a69e-039c-68c2-7377f902768e%404vrs.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/01f47251-a69e-039c-68c2-7377f902768e%404vrs.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> Victor Sudakov
>> Systems Administrator
>> Streamline - Property Management Software
>> Website: www.streamlinevrs.com
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/4ea64a90-9347-48d6-b4e7-cfc013bc659a%404vrs.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/4ea64a90-9347-48d6-b4e7-cfc013bc659a%404vrs.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_CMo%3D7nYQjWOo_H-75LfLTH9Dq2MzJfsEZ4w1SuZpNdZA%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_CMo%3D7nYQjWOo_H-75LfLTH9Dq2MzJfsEZ4w1SuZpNdZA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> --
> Victor Sudakov
> Systems Administrator
> Streamline - Property Management Software
> Website: www.streamlinevrs.com
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/5a24d450-e8c0-8f22-4c34-03031f81444e%404vrs.com
> <https://groups.google.com/d/msgid/jenkinsci-users/5a24d450-e8c0-8f22-4c34-03031f81444e%404vrs.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CAESUf_A3DKVfm1S56EUbSYwNa4p5_GQOQX%3D_SMNXuwoFb4sO0w%40mail.gmail.com.