Try

credentials(env.BRANCH_NAME='main' ? 'PROD_CLIENT_ID' : 'DEV...')

or some syntax like that..

On Mon, 28 Nov 2022, 06:05 Victor Sudakov, <v...@4vrs.com> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPzq3pemjoPXo%3DcCeC9oEwdNhD88VqXM6BvBRbZUsQoba172jw%40mail.gmail.com.

Reply via email to