1 year ago

#387727

test-img

a11eksandar

how to get value from file before first commit

I have a command which returns me a "version" from api.yaml file:

branch=$(grep 'version:' api.yaml | awk  '{print $2}')
echo "Branch version is:" $branch

also I have a command which returns me a "Version" value for a merge request source branch name:

origin=$(git show "origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" -- api.yaml | grep version | grep '^\-' | awk  '{print $3}')
echo "Origin branch is:" $origin

When I change a version and do a commit I get a currnet version, that is fine! But command which should return me source branch name value, returns me value of last commit and not the first. So, when I have multiple commits, I always get the latest commit version and not the first versio.

what should be the command that returns me first value of "version" in branch?

git

gitlab

continuous-integration

0 Answers

Your Answer

Accepted video resources