Re: Is there a way to pass environment variables from Upstream Job to a Downstream Job without writing properties file to disk or creating extra job parameters?

2017-06-09 Thread Victoria Kozel
Thank you Randy. 

This is very helpful. Using Hidden Parameter allows me to pass a property 
from Upstream to Downstream without writing it into an ugly properties file 
on the disk. The reason I need Hidden Parameter in the first place is 
because passing a groovy generated list of choices as a "Current Build 
Parameter" explodes with exception (Extensible Choice Parameter plugin). So 
I have to use two different parameters for a single purpose depending on 
wether a job has been started by Upstream Build or Manually. BUILD_CAUSE 
workaround worked OK - Hidden Parameter is also a workaround, but has one 
less step.


On Thursday, June 8, 2017 at 2:56:21 PM UTC-7, Jackson, Randy wrote:
>
> You don’t specify why you don’t want to create extra job parameters, but 
> if it is to prevent users that run the downstream job from setting it when 
> firing off the build, then I would suggest using a combination of the 
> Hidden Parameters plugin and the Parameterized Build Trigger plugin.
>
>  
>
> The Hidden Parameters plugin would allow you to add a parameter in the 
> downstream job that you could set the name to UPSTREAM_TRIGGERED and set 
> the default value to FALSE.  Users running the downstream job would not see 
> the parameter when they click the Build With Parameters Button, but the 
> parameter could be used say with a batch script or any other way a 
> parameter is accessed.
>
>  
>
> Then use the “Trigger parameterized build on other projects” on your 
> upstream job and select Predefined Parameters.  There you can add:
>
> UPSTREAM_TRIGGERED=TRUE
>
> So when it runs and triggers the job, it will set that parameter in the 
> downstream job to TRUE and you will know it was triggered by the upstream 
> build.
>
> You can also pass other defined parameters or environment variables such 
> as build number or job name by using the ${ParameterName} such as:
>
> UPSTREAM_JOB_NAME=${JOB_NAME}
>
> UPSTREAM_BUILD_NUMBER=${BUILD_NUMBER}
>
> Just be sure the UPSTREAM_JOB_NAME and UPSTREAM_BUILD_NUMBER parameters 
> are added as a parameter, hidden or otherwise in your downstream job.
>
>  
>
> Hope that help.
>
>  
>
>  
>
> *From:* jenkins...@googlegroups.com  [
> mailto:jenk...@googlegroups.com ] *On Behalf Of *Victoria 
> Kozel
> *Sent:* Thursday, June 08, 2017 4:28 PM
> *To:* Jenkins Users
> *Subject:* Is there a way to pass environment variables from Upstream Job 
> to a Downstream Job without writing properties file to disk or creating 
> extra job parameters?
>
>  
>
> Hello,
>
>  
>
> I am trying to pass environment variables from Upstream Job to a 
> Downstream Job without writing properties file to disk or creating extra 
> job parameters. Basically, my Downstream job needs to know if it was 
> triggered by upstream or not.
>
>  
>
> Thanks!!
>
> -- 
> 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/81b57a38-968e-4a24-a4a0-5c85cf9e6c1e%40googlegroups.com
>  
> 
> .
> For more options, visit https://groups.google.com/d/optout.
> --
> This email is intended solely for the named addressee(s) and may be 
> confidential or contain privileged information. Review, disclosure, 
> copying, distribution, or use of this email by anyone other than an 
> intended recipient is strictly prohibited. If you received this email in 
> error, please delete it from your system and notify the sender immediately. 
> While precautions have been taken to help ensure no computer viruses are 
> present, there is a risk whenever transmitting emails or downloading 
> attachments. The sender will not be liable for any loss or damage resulting 
> from any malware in this communication or for improper or incomplete 
> transmission of its contents or for any delay in its receipt. 
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/eda53218-30f8-4011-9b18-823fd3000318%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Is there a way to pass environment variables from Upstream Job to a Downstream Job without writing properties file to disk or creating extra job parameters?

2017-06-08 Thread Jackson, Randy
You don’t specify why you don’t want to create extra job parameters, but if it 
is to prevent users that run the downstream job from setting it when firing off 
the build, then I would suggest using a combination of the Hidden Parameters 
plugin and the Parameterized Build Trigger plugin.

The Hidden Parameters plugin would allow you to add a parameter in the 
downstream job that you could set the name to UPSTREAM_TRIGGERED and set the 
default value to FALSE.  Users running the downstream job would not see the 
parameter when they click the Build With Parameters Button, but the parameter 
could be used say with a batch script or any other way a parameter is accessed.

Then use the “Trigger parameterized build on other projects” on your upstream 
job and select Predefined Parameters.  There you can add:
UPSTREAM_TRIGGERED=TRUE
So when it runs and triggers the job, it will set that parameter in the 
downstream job to TRUE and you will know it was triggered by the upstream build.
You can also pass other defined parameters or environment variables such as 
build number or job name by using the ${ParameterName} such as:
UPSTREAM_JOB_NAME=${JOB_NAME}
UPSTREAM_BUILD_NUMBER=${BUILD_NUMBER}
Just be sure the UPSTREAM_JOB_NAME and UPSTREAM_BUILD_NUMBER parameters are 
added as a parameter, hidden or otherwise in your downstream job.

Hope that help.


From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Victoria Kozel
Sent: Thursday, June 08, 2017 4:28 PM
To: Jenkins Users
Subject: Is there a way to pass environment variables from Upstream Job to a 
Downstream Job without writing properties file to disk or creating extra job 
parameters?

Hello,

I am trying to pass environment variables from Upstream Job to a Downstream Job 
without writing properties file to disk or creating extra job parameters. 
Basically, my Downstream job needs to know if it was triggered by upstream or 
not.

Thanks!!
--
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/81b57a38-968e-4a24-a4a0-5c85cf9e6c1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This email is intended solely for the named addressee(s) and may be 
confidential or contain privileged information. Review, disclosure, copying, 
distribution, or use of this email by anyone other than an intended recipient 
is strictly prohibited. If you received this email in error, please delete it 
from your system and notify the sender immediately. While precautions have been 
taken to help ensure no computer viruses are present, there is a risk whenever 
transmitting emails or downloading attachments. The sender will not be liable 
for any loss or damage resulting from any malware in this communication or for 
improper or incomplete transmission of its contents or for any delay in its 
receipt.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3994D3AA09885B4CACC3D00FFD60221F010BA4921C%40MX-EXMB1-PRD.infarmbureau.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there a way to pass environment variables from Upstream Job to a Downstream Job without writing properties file to disk or creating extra job parameters?

2017-06-08 Thread Victoria Kozel
Richard, thank you! This is exactly what I was looking for!


On Thursday, June 8, 2017 at 1:37:49 PM UTC-7, Richard Ginga wrote:
>
> I think there is a BUILD_CAUSE token that every freestyle job gets when it 
> runs. 
>
> Check the Environ Injector Plugin for more details
>
> On Thu, Jun 8, 2017 at 4:28 PM, Victoria Kozel  > wrote:
>
>> Hello,
>>
>> I am trying to pass environment variables from Upstream Job to a 
>> Downstream Job without writing properties file to disk or creating extra 
>> job parameters. Basically, my Downstream job needs to know if it was 
>> triggered by upstream or not.
>>
>> Thanks!!
>>
>> -- 
>> 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/81b57a38-968e-4a24-a4a0-5c85cf9e6c1e%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Dick Ginga
> Build Engineer
> rgi...@disruptorbeam.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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0ba8d4b1-e282-48d3-bfdf-508666c50998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there a way to pass environment variables from Upstream Job to a Downstream Job without writing properties file to disk or creating extra job parameters?

2017-06-08 Thread Richard Ginga
I think there is a BUILD_CAUSE token that every freestyle job gets when it
runs.

Check the Environ Injector Plugin for more details

On Thu, Jun 8, 2017 at 4:28 PM, Victoria Kozel 
wrote:

> Hello,
>
> I am trying to pass environment variables from Upstream Job to a
> Downstream Job without writing properties file to disk or creating extra
> job parameters. Basically, my Downstream job needs to know if it was
> triggered by upstream or not.
>
> Thanks!!
>
> --
> 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-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/jenkinsci-users/81b57a38-968e-4a24-a4a0-5c85cf9e6c1e%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Dick Ginga
Build Engineer
rgi...@disruptorbeam.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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAL3PpaVxn2Fw7N2TJVy8OdFL82kx9uDE%2BO8i3vHy4xq7K1SEBA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.