How can I set a logical statement to skip the commands if the branch matches the regex?
I tried to add the following to filter out if branch are created by Dependabot but seems like the CircleCI build is not accessing the logical statements and continue to run even if my branch name is dependabot.workflow
equal: [ /^dependabot.*/ , << pipeline.git.branch >>]
Currently, conditional logic does not support regular expressions. You can however use branch level job execution with regular expressions.
Thanks for that. But that doesn’t really help. Instead, I just added the following if else on the command to skip it if the branch name starts with dependabot.
description: "Build docker image command"
name: Run docker build
if [[ ! << pipeline.git.branch >> =~ ^dependabot.* ]]; then
docker build .
echo "skip this run step"
Nice solution @guohaolee!
Unfortunately, this solution won’t stop the resource allocation. It would better to have at least two condition operators like
ends_with @Henna, otherwise, thinking on the workflow level, if you have 3 jobs which should be filtered by branch, you have to repeat the
filter/branches/only over and over again.
A solution like:
starts_with: [ "dependabot" , << pipeline.git.branch >>]
Hi @vpereira ,
That is a great point! At the time when this post was created, we did not support using regular expressions for branch filtering on a workflow level. We do now!
We do not currently have a
starts_with key but you could use a regular expression in a logic statement to do what you described above.
You can also create an feature request on CircleCI’s ideas page for
Hey @Henna thank you for your reply!