Skip to content
Advertisement

Get version number of a dependency from pom.xml using command line and use that version number to tag a docker image

I have a pom file. I want to read the version of the first dependency in the dependencies tag and use that version to tag our docker image.

I am using this command to get the project version.

mvn help:evaluate -Dexpression=project.parent.version:1 -q -DforceStdout

I want to get the version of the first dependency using command line , and from there it will passed onto the docker tag and docker push.

enter image description here

Advertisement

Answer

You could try

project.dependencies[0].version

but probably the most stable method would be to define the version as a property and then read the property with help:evaluate.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement