Injecting environment variables - sourcing shell script

1,399 views
Skip to first unread message

Victoria Kozel

unread,
Jun 12, 2017, 1:49:26 PM6/12/17
to Jenkins Users
Hello,

I need to use a certain variable in my Shell Build Step that is figured in a shell script stored on the node. When I "source" this script in the same step in which I need the variable, it works. However sourcing it in the EnvInject step under Build Environment phase does not seem to transfer the variable to the Build Step. Here's how the job is configured:

X . Inject environment variables to the build process

Script Content: source /home/jenkins/setInventoryVar.sh



I can see at this point the output of the script in the console, yet the Build Step does not inherit a variable set in Inject Env.

Suggestions are greatly appreciated.

Eric Pyle

unread,
Jun 12, 2017, 2:24:29 PM6/12/17
to jenkins...@googlegroups.com
The help for "Script Content" confirms that it can't be used to set environment variables for the build. But you should be able to specify the path to your shell script in "Properties File Path" instead.
--
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/dd621d0a-5a08-40a3-913c-54535f12cc5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Eric Pyle
Siemens PLM Software
Lebanon, NH
+1 603-277-3060
eric...@siemens.com
http://www.siemens.com/plm

Jackson, Randy

unread,
Jun 12, 2017, 5:05:33 PM6/12/17
to jenkins...@googlegroups.com

Have you looked at the Environment Script Plugin?

I use it to generate parameters that I need to use later in my builds.

 

https://wiki.jenkins.io/display/JENKINS/Environment+Script+Plugin

--

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/dd621d0a-5a08-40a3-913c-54535f12cc5f%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.

Victoria Kozel

unread,
Jun 13, 2017, 5:50:11 PM6/13/17
to Jenkins Users, Randy....@infarmbureau.com
Thank you Randy for the suggestion. I installed the plugin, but even though it showed up in my Build Environment Phase it runs with an error. I am probably going to simply source my shell script in the build step itself - I don't like doing it, but the upside is that it requires fewer plugins.

Thank you!
Reply all
Reply to author
Forward
0 new messages