I need bash to check whether CI_COMMIT_REF_NAME matches either the string master, or a three part version number like 1.3.5, 1.1.11 and so on.
Here's what I tried:
#!/bin/bash
CI_COMMIT_REF_NAME=1.1.4
if [ $CI_COMMIT_REF_NAME == 'master' ] || [[ $CI_COMMIT_REF_NAME =~ ^([0-9]{1,2}\.){2}[0-9]{1,2}$ ]]
then
echo "true"
else
echo "false"
fi
The expected output is true, but I get false. Setting the variable to master works as intended, so the mistake must be my regex.
What am I doing wrong?