Reputation: 11
I am having some trouble with gitlab-ci. I have a maven project and I want to build the image with the version.
What I'm actually doing:
stages:
- build_maven
test_build:
stage: build_maven
script:
- export VERSION=$(mvn --non-recursive help:evaluate -Dexpression=project.version | grep -v '\[.*')
- docker build --build-arg VERSION=$VERSION --no-cache -t registry.gitlab.com/mycompany/myproject/service-mine:$VERSION .
- docker pushregistry.gitlab.com/mycompany/myproject/service-mine:$VERSION .
tags:
- myserver
only:
- development
But version variable is not available. I also tried to put everything in a shell script but still the same the variable VERSION is empty. Does someone have an idea ? Thanks
Upvotes: 0
Views: 180
Reputation: 11
This worked
export VERSION=`mvn --non-recursive help:evaluate -Dexpression=project.version | grep -v '\[.*'`
Upvotes: 1