Access Maven Metadata Plugin parameters in Jenkins pipeline Groovy script

214 views
Skip to first unread message

kelemensanyi

unread,
Sep 12, 2016, 9:20:39 AM9/12/16
to Jenkins Users

Hi,

How can I access the values of the parameters provided by "Maven Metadata Plugin" in the Jenkins pipeline Groovy script?

I created a job with two parameters:

    Name           Type
    -------------  -------------
    SomeStr        String Parameter
    SomeArtifact   List maven artifact versions

Pipeline Groovy script:

  node {

    // This is OK
    println 'SomeStr: '    + SomeStr

    // These DON'T WORK
    println 'SomeArtifact: ' + SomeArtifact
    println 'SomeArtifact: ' + SomeArtifact_VERSION
    println 'SomeArtifact: ' + System.getenv('SomeArtifact')
    println 'SomeArtifact: ' + System.getenv('SomeArtifact_VERSION')

  }

While the value of SomeStr is printed correctly, none of the above attempts work for the SomeArtifact property. I tried it with and without Groovy Sandbox as well, but no luck.

Versions: Jenkins 2.14, Maven Metadata Plugin for Jenkins CI server 1.4.1, Pipeline 2.1

Best Regards,
Sándor

Timo Weber

unread,
Jan 16, 2017, 1:41:02 PM1/16/17
to Jenkins Users
Just found your question because I have exactly the same problem. Could you somehow solve this?

Timo

Indra Gunawan (ingunawa)

unread,
Jan 16, 2017, 3:00:49 PM1/16/17
to jenkins...@googlegroups.com

?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3cbf93e4-9956-42eb-982c-2cc0b61458f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kelemensanyi

unread,
Jan 16, 2017, 3:33:56 PM1/16/17
to Jenkins Users
Hi Timo,

No, we chose a completely different approach.

But I recently got an answer to the same question on stackoverflow (from Torsten Reinhard):

String version = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter("COMPONENT").version

I couldn't verify it, but I hope it helps you.
Please let me know if this solution works for you as well.

Ciao,
Sándor

Timo Weber

unread,
Jan 17, 2017, 3:25:46 AM1/17/17
to Jenkins Users
Hi Sándor,

thanks a lot for the link. The workaround works for me. You have to disable the Groovy sandbox though.

 Timo
Reply all
Reply to author
Forward
0 new messages