Hi everyone!
I have following configuration which builds and pushes my project as image into dockerhub
pipelines:
branches:
master:
- step:
services:
- docker
script:
- mvn clean install
- export IMAGE_NAME=org/project:$BITBUCKET_COMMIT
- docker build -t $IMAGE_NAME .
- docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
- docker push $IMAGE_NAME
This works fine and was easy to setup. Now, I want to tag my images with the current version of my project, which is specified in the *pom.xml* which lies in the root directory.
How can I read/extract/store the version of my project and use it as tag for a docker image?
Cheers,
Alexander
Please have a look at below if it could help you.
```
export VERSION=$(awk 'FNR==5' pom.xml)
```
it will export 5th line of the file.
```
docker build -t $IMAGE_NAME:VERSION .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.