Update:
I solved that and i added my solution, on the bottom, for reference.
Update:
After searching and digging i found a git script that gives the version tag:
git log --decorate -n 1 --oneline | cut -d: -f2 | cut -d, -f.
So that command, local on my the terminal, gives just the version tag : v1.0.7
But when this git is executed inside the gitlab-ci.yml file, it returns always nothing/empty.
gitlab-ci.yml:
...
export USER_TAG=$(git rev-parse HEAD)
export STAGE_TAG=$(git log --decorate -n 1 --oneline $USER_TAG | cut -d: -f2 | cut -d, -f1 | xargs)
echo "*ver tag: $STAGE_TAG"
It is like the git command is ignored, i dont know why this is happening, i need to search again.
I m creating my gitlab-ci.yml file so that the Ci/CD pipeline starts when i push tags.
I need to make the pipeline start on specific combination of 2 TAGS, a version e.g. v1.0.0 and DEV_TEST and not on just one TAG.
My commit that triggers the pipeline is like so (<DEV_TEST><v1.0.7>):

Into my gitlab-ci.yml i have a script that takes the $CI_COMMIT_TAG, but it just takes the DEV_TEST tag and ignores the version tag:
build:dev:
stage: build:dev
only:
refs:
- /^DEV_TEST/
script: |
set -e
echo
echo
echo "################################################################################"
echo "# Building Docker Base Image"
echo "################################################################################"
echo
echo
# ---- build image from branch ---- #
if [ "$CI_COMMIT_TAG" != "" ];
# ---- Build image from tag ---- #
then echo "building from tag branch $CI_COMMIT_TAG"
docker build -t $CONTAINER_TEST_IMAGE -f Dockerfile .
docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
export TAG_VERSION=$(echo $CI_COMMIT_TAG | cut -d '-' -f1)
fi
What i do is:
- push a version tag first, e.g. v1.0.0
- push the tag
DEV_TEST, and based on the rule, the pipeline starts - but this line: then echo "building from tag branch $CI_COMMIT_TAG"
gives the
DEV_TESTtag only. So i m wondering is there a way to get both tags ?
:CI_COMMIT_TAG` and i miss the version tag. I manage to get the version tag if i run the above command on my terminal like so:git log --decorate -n 1 --oneline | cut -d: -f2 | cut -d, -f1, so far so good. Now the issue is that this git command returns nothing, inside thegitlab-ci.yml. To answer your question, those answers are not as i need because i need to get just the version tag and not all the tags of the commit.gitlab-ci.yml- apk add --no-cache curl jq python3 py-pip git - pip install awscli botocore==1.26.1 All good now. :)