I’m pulling my hair here and before I don’t have not one left I thought I may ask first for an easy solution to that simple problematic :
depending on the branch, I want to execute the exact same workflows/jobs, but with different contexts
That simple right ?
Hi there and thanks for posting on CircleCI Discuss!
You can leverage the
filter parameter to ensure jobs only run on the branches you set. You can specify which context you’d like to use for each job as well. So something like:
If you add
jobA twice in the same workflow, it will run with a numeric value added to the end of the job name while building to differentiate the duplicate job.
I hope this helps!
Hi and thanks for the answer !
My workflow/jobs are eaxctly the same, I just want to, depending on the branch, to switch the context.
I’d rather not duplicate the jobs
Another hack you can do is to include the branch name in your context, so you can do something like:
context: context_<< pipeline.git.branch >>
Although it would be great if
when clause is supported for context as well
Does pipeline.git.branch gets reconized. I get the below error. Does the above code work for anyone?
" Could not find context “context_<< pipeline.git.branch >>”. "