Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-12-05 Thread Arnaud bourree
Hi, So many ways to do the same: - have credentials name with branch name in (my personal choise) - define a pipeline method to switch/read map - imbrication of ternary operator Arnaud Le lun. 5 déc. 2022, 10:11, Victor Sudakov a écrit : > What would you do if you needed multiple branches with

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-12-05 Thread Victor Sudakov
What would you do if you needed multiple branches with multiple choices of variables, like a "case" or "if ... else ... elif" operators? On 02.12.2022 13:33, Arnaud bourree wrote: environment {   SERVICE_KEY = credentials("${env.BRANCH_NAME.equals('master') ? 'PROD_SERVICE_KEY' : 'SERVICE_KE

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-12-01 Thread Arnaud bourree
environment { SERVICE_KEY = credentials("${env.BRANCH_NAME.equals('master') ? 'PROD_SERVICE_KEY' : 'SERVICE_KEY'}") Le ven. 2 déc. 2022, 03:05, Victor Sudakov a écrit : > Hello Arnaud, > > Can you please post the whole line within environment{} as you suggest it > should look? > > On 02.12.20

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-12-01 Thread Victor Sudakov
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 me

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-12-01 Thread Arnaud bourree
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 a écrit : > This syntax may be operational, but I need more testing: > > environment { > > SERVICE_KEY = cr

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-11-29 Thread Victor Sudakov
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

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-11-29 Thread Victor Sudakov
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

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-11-29 Thread James Nord
Try credentials(env.BRANCH_NAME='main' ? 'PROD_CLIENT_ID' : 'DEV...') or some syntax like that.. On Mon, 28 Nov 2022, 06:05 Victor Sudakov, wrote: > Dear Colleagues, > > Can you please suggest a way to use different credentials depending on the > Git > branch in a multi-branch pipeline? In oth

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-11-28 Thread Victor Sudakov
Hello John, I use folders too to organize jobs together and to keep credentials in separate domains. However, the automatic creation of jobs based on git branches is important to me therefore I use MultiBranch pipelines. Do I understand correctly that you have scripted your own implementation of

Re: substituting different credentials() in a multibranch pipeline depending on branch

2022-11-28 Thread John Patrick
Due to similar issues, I changed how I was doing it from a single MultiBranch project. I've now separate projects for each environment, also use https://plugins.jenkins.io/cloudbees-folder to create prod and dev folders which container the environment specific values. Have a groovy script that crea