Build Parameters in Plugin not working

12 views
Skip to first unread message

Jean-Karlo Accetta

unread,
Jan 24, 2018, 12:10:23 PM1/24/18
to Jenkins Developers
Hi all,

I created a plugin which adds a build step with a simple textbox to any job.  Whenever the job is built, I print out the value of that textbox to the console.

The problem is that whenever I set that value to be a parameter of the build (see image), the console simply prints the parameter's name, not its value.



In this case, it simply printed out $COMMENT instead of its value.

Please help -- I tried using System.getProperty() but that didn't really work either (it returned a null string).

Jesse Glick

unread,
Jan 24, 2018, 12:57:32 PM1/24/18
to Jenkins Dev
On Wed, Jan 24, 2018 at 12:10 PM, Jean-Karlo Accetta
<jeankarl...@gmail.com> wrote:
> I tried using System.getProperty() but that didn't really work either

Certainly not—that would be a system property global to the master JVM!

Try:

http://javadoc.jenkins.io/hudson/model/Run.html#getEnvironment-hudson.model.TaskListener-
http://javadoc.jenkins.io/hudson/EnvVars.html#expand-java.lang.String-

If implementing `SimpleBuildStep` for Pipeline compatibility, do this
only for an `AbstractBuild`:

https://jenkins.io/doc/developer/plugin-development/pipeline-integration/#variable-substitutions

Also see:

https://issues.jenkins-ci.org/browse/JENKINS-35671

Jean-Karlo Accetta

unread,
Jan 24, 2018, 1:20:50 PM1/24/18
to Jenkins Developers
Hi Jesse,

I had tried run.getEnvironment(listener) as well but hadn't tried the .overrideAll(((AbstractBuild<? ,?>)(run)).getBuildVariables()).expand(this.whatever).

Thanks a lot, that did it!
Reply all
Reply to author
Forward
0 new messages