Get POM Version from Jenkins Pipeline

1,225 views
Skip to first unread message

Hongguo An

unread,
Feb 4, 2018, 1:19:59 AM2/4/18
to Jenkins Users
Hi:
I am using Jenkins 2.104, I am using pipeline from Jenkinsfile. What is the right way to get POM Version? I have the pipeline-utility-steps-plugin installed.
If I using
{

pipeline{

environment 

    {

        ECRURL = 'https://353705521121.dkr.ecr.us-east-1.amazonaws.com'

        AWS_REGION = 'us-east-1'

        VERSION = readMavenPom().getVersion()

    }

}
}

//If says getVersion can't be called.
If I use 

def pom = readMavenPom() in any place of the file, it says the readMavenPom is not defined.

Please help to fix this

Torsten Reinhard

unread,
Feb 5, 2018, 4:52:54 PM2/5/18
to Jenkins Users
If you´re inside a "node" and your workspace has a valid pom.xml file, readMavenPom() should do the magic.
You could than acess the version using

def pom = readMavenPom()
def version = pom.version

Torsten

Hongguo An

unread,
Feb 5, 2018, 5:12:53 PM2/5/18
to Jenkins Users
Thanks, so I need to do it this way?
{
pipeline{
node{
def pom = readMavenPom()
def version=pom.version

agent any

tools {

    maven '3.x'

}

stages{}

}

}

}?

Reply all
Reply to author
Forward
0 new messages