Search code examples
mavenjenkinsjenkins-cli

Print pom.xml components variable in Jenkins


I am having one pom.xml and I am building maven project in Jenkins. I want to print stuff like: Artifactid, Version, group ID. Which is present in pom.

I want to do it Jenkins itself without any plugins. Any help would be appreciated.


Solution

  • You can do this with the maven help plugin. Just use a "Execute Shell" Build Blog and write some bash code like this:

    version=$(mvn help:evaluate -Dexpression=project.version | egrep -v "INFO|WARNING|ERROR")
    echo $version
    

    You can also check the topic How to get Maven project version to the bash command line for more possible solutions.