Re: Variable substitution in Jenkins plugin

2015-05-31 Thread Adrien Lecharpentier
Hello,

You can also use the token macro plugin to do such things:
https://wiki.jenkins-ci.org/display/JENKINS/Token+Macro+Plugin

-- Adrien

Le dim. 31 mai 2015 20:29, Daniel Beck  a écrit :

>
> On 30.05.2015, at 17:41, p...@pholding.co.uk wrote:
>
> > Does the Jenkins API provide a better solution that would allow my
> plugin to substitute a variable with a real value when the build job is
> executed?
>
>
> http://javadoc.jenkins-ci.org/hudson/EnvVars.html#expand%28java.lang.String%29
>
> --
> 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 jenkinsci-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/EA1537DF-CAEF-409F-8F07-36186DCB1535%40beckweb.net
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAKwJSvwH45bpTSrzHkba_Oi6Qy%2BM2SMx0t3CyotrnTH71h%2BfWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Variable substitution in Jenkins plugin

2015-05-31 Thread Daniel Beck

On 30.05.2015, at 17:41, p...@pholding.co.uk wrote:

> Does the Jenkins API provide a better solution that would allow my plugin to 
> substitute a variable with a real value when the build job is executed?

http://javadoc.jenkins-ci.org/hudson/EnvVars.html#expand%28java.lang.String%29

-- 
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 jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/EA1537DF-CAEF-409F-8F07-36186DCB1535%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.


Variable substitution in Jenkins plugin

2015-05-30 Thread paul


I'm developing a new Jenkins plugin that will be executed during the build 
phase of a Jenkins job and have a requirement to allow the user to specify 
a variable name (as opposed to a literal value) in the job configuration 
for the plugin. The intention is that when the job executes the variable 
name specified by the user will then be substituted with the real value 
associated with the variable and that the plugin will then use this real 
value when running the perform method.

For example if the variable MY_VARIABLE with the value myValue was injected 
into the build environment by another part of job and the value 
${MY_VARIABLE} was specified in the job configuration for my plugin, then I 
would like the plugin to substitute ${MY_VARIABLE} with the real value for 
the variable which is myValue.

[image: enter image description here]

Having done some research I understand that Jenkins does not automatically 
substitute variable in the job configuration for their respective values 
and this must be handled by the plugin. What I haven't been able to work 
out is the best way to perform the substitution in my plugin. The only 
solution I've found so far is the parse the string passed from the job 
configuration to see whether it matches the correct pattern for a variable 
and then lookup the value in my code.

Does the Jenkins API provide a better solution that would allow my plugin 
to substitute a variable with a real value when the build job is executed?

-- 
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 jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/5a55cc4f-d0c4-45b6-8603-04648e2e0240%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.