Ignore a branch regex

2.0

#1

How do we ignore branches in 2.0? I don’t see anything in the getting started. We have far too many steps to put a conditional on each one.


#2

Currently unsupported. Here’s the best solution I can think of right now:

for branch in production development staging foo bar ; do if [[ $CIRCLE_BRANCH == $branch ]] ; then exit 1 ; fi ; done

A quick test:

root@08a543052127:~$ export CIRCLE_BRANCH=master
root@08a543052127:~$ for branch in production development staging foo bar ; do if [[ $CIRCLE_BRANCH == $branch ]] ; then exit 1 ; fi ; done
root@08a543052127:~$ export CIRCLE_BRANCH=production
root@08a543052127:~$ for branch in production development staging foo bar ; do if [[ $CIRCLE_BRANCH == $branch ]] ; then exit 1 ; fi ; done
exit

#3

So you are suggesting putting a conditional on each and every step, or is there an earlier place to put this to get out quicker?


#4

Ah, make this an early step?


#5

Run it as the first step to just fail the build. The downside is this will report a failed build for those branches.


#6

Whitelisting and blacklisting of branches is now supported on 2.0: https://circleci.com/docs/2.0/configuration-reference/#branches


#7

Thanks @tom, but this doesn’t appear to be working for me - simply ignoring master. Can you take a look at https://circleci.com/gh/alienfast/ci-image/46 and let me know what I may have missed? Or has this change not fully rolled out?


#8

It needs to be under the build section, not at the root level.


#9