I have the following strings: deploy_tag and version_number .
deploy_tag can be "2.8.6.1" or "origin/master" and version_number can only be numeric separated by dots like "1.1.2.3".
I want to do something like that:
if [[ $deploy_tag == *["\/"+]* ]]; then deploy_tag=$version_number; fi
Meaning: If $deploy_tag contains "/" then set it's value with the value of $version_number.
This whole shell script is part of a shell execution within a Jenkins job.
The problem is that seems like something is wrong with my regex but I can't find what... can you?
I checked some other questions on stackoverflow but I couldn't find the issue with my regex.
Edit #1: Here's an example from Jenkins build log:
[social-portal] $ /bin/sh -xe /tmp/hudson1162745529550311655.sh
+ [[ origin/master =~ / ]]
/tmp/hudson1162745529550311655.sh: 2: /tmp/hudson1162745529550311655.sh: [[: not found
+ echo deploy: origin/master
deploy: origin/master
+ echo version: 2.7.4
version: 2.7.4
+ mkdir output
And that's the code which generates the problem (including debug echo's):
if [[ $DEPLOY_TAG =~ / ]]; then DEPLOY_TAG=$VERSION_NUMBER; fi
echo deploy: $DEPLOY_TAG
echo version: $VERSION_NUMBER