0

I have a simple branch to match during circleci build, but for some reason it just won't match

echo $CIRCLE_BRANCH #this variable is "release-0.0.2"

if [[ $CIRCLE_BRANCH =~ ^release-\d+\.\d+\.\d+ ]]; then
    echo "release branch"
elif [[ $CIRCLE_BRANCH == master ]]; then
    echo "master branch"
fi

# Output
# release-0.0.2

I expect the echo "release branch" to run, but ^release-\d+\.\d+\.\d+ doesn't seem to match release-v0.0.2.

I have tested the regex in an online regex tool and it seems to be correct.

I also tried putting quotes and "/"s around the regex but still no luck

Emma
  • 27,428
  • 11
  • 44
  • 69
Patrick Mao
  • 1,013
  • 1
  • 8
  • 12
  • Do you have "release-0.0.2" or "release-v0.0.2" ? Notice the difference of "v". – NeverHopeless Aug 07 '19 at 05:02
  • Replace `\d+` with `[[:digit:]]+`, since `\d` is a PCRE extension; they are not present in the ERE (Posix Extended Regular Expression) supported by bash – Inian Aug 07 '19 at 05:09

0 Answers0