Can the CircleCI config be changed based on the branch in use?

It would be great if there were a second configuration file. That file could could have specific instructions pertaining to whichever branch the commit came from, and could be referenced from .circle/config.yml. Maybe there is a way to have specific deployment instructions per branch and I haven’t found it in the docs.

Would you give an example of how you’d want to differentiate your configuration? If it is just different shell commands, you could write a shell script to detect the branch and run different commands depending on the branch name.

If however you want different steps or workflow shape, I don’t think that is supported. Pop it in the ideas box?

Maybe I’ve missed some documentation. Is there a best practice for forming shell scripts to manage GitFlow? Basically I’m looking for a way to promote artifacts once I’ve tested in my release branch.

I’ve not tried that myself, sorry - perhaps searching for “gitflow” here in the forum would be worthwhile, or check the docs/blog? Or maybe someone else can chip in.

Yep. Those are good suggestions. Great minds think alike! I did check the docs and the blog, but the only entries reference v1.0 which is going to be sunsetted soon.

Thank you for taking the time to respond. I’ll keep searching/experimenting

1 Like

The branch name is available as an environment variable. So checking that variable and implementing any conditional logic you’d like in Bash (or similar) would make sense.

Using Workflows, you can also have whole jobs only execute based on specific branches or a branch regex.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.