Build Parameters in Plugin not working

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Build Parameters in Plugin not working

Jean-Karlo Accetta
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).

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/076f9099-da56-46d0-95e5-1ff060449e47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Build Parameters in Plugin not working

Jesse Glick-4
On Wed, Jan 24, 2018 at 12:10 PM, Jean-Karlo Accetta
<[hidden email]> 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

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1V%2BObK3_nY6pFJ8i4k4wi6A5HV0fOnfWHoGip5FJBn7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Build Parameters in Plugin not working

Jean-Karlo Accetta
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!

On Wednesday, January 24, 2018 at 12:57:32 PM UTC-5, Jesse Glick wrote:
On Wed, Jan 24, 2018 at 12:10 PM, Jean-Karlo Accetta
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="T7F9yw9qBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jeankarl...@...> 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:

<a href="http://javadoc.jenkins.io/hudson/model/Run.html#getEnvironment-hudson.model.TaskListener-" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjavadoc.jenkins.io%2Fhudson%2Fmodel%2FRun.html%23getEnvironment-hudson.model.TaskListener-\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGIUfq9fEKXNag0mHw2Wv1UBn1EAA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjavadoc.jenkins.io%2Fhudson%2Fmodel%2FRun.html%23getEnvironment-hudson.model.TaskListener-\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGIUfq9fEKXNag0mHw2Wv1UBn1EAA&#39;;return true;">http://javadoc.jenkins.io/hudson/model/Run.html#getEnvironment-hudson.model.TaskListener-
<a href="http://javadoc.jenkins.io/hudson/EnvVars.html#expand-java.lang.String-" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjavadoc.jenkins.io%2Fhudson%2FEnvVars.html%23expand-java.lang.String-\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFLN6s0mTv-88iZ1Cx5p27uw69gXQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjavadoc.jenkins.io%2Fhudson%2FEnvVars.html%23expand-java.lang.String-\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFLN6s0mTv-88iZ1Cx5p27uw69gXQ&#39;;return true;">http://javadoc.jenkins.io/hudson/EnvVars.html#expand-java.lang.String-

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

<a href="https://jenkins.io/doc/developer/plugin-development/pipeline-integration/#variable-substitutions" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fdeveloper%2Fplugin-development%2Fpipeline-integration%2F%23variable-substitutions\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJkt-O3WsqqzmE5aWu8GvL4_G1Zg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjenkins.io%2Fdoc%2Fdeveloper%2Fplugin-development%2Fpipeline-integration%2F%23variable-substitutions\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJkt-O3WsqqzmE5aWu8GvL4_G1Zg&#39;;return true;">https://jenkins.io/doc/developer/plugin-development/pipeline-integration/#variable-substitutions

Also see:

<a href="https://issues.jenkins-ci.org/browse/JENKINS-35671" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-35671\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGB9sn6Qvw5n_x-dds3tzUmkzBizQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fissues.jenkins-ci.org%2Fbrowse%2FJENKINS-35671\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGB9sn6Qvw5n_x-dds3tzUmkzBizQ&#39;;return true;">https://issues.jenkins-ci.org/browse/JENKINS-35671

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/48db37e1-f667-49d3-bb4e-743f24f5092b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.