To apply environment variables, you have to wrap your code in a withEnv
block, whose argument is an array of strings of the form
'VARIABLE=value'. So you could read the env-setup file and go through
line by line building up an environment array, then use that array
variable in the withEnv block. Or you could put all your Ansible
commands in a shell script, and include the "source
/opt/ansible/hacking/env-setup" as one of the first lines in the script.
You could use the writeFile step to create such a shell script on the
fly if desired.
Eric
On 7/6/2016 11:20 AM, Tuomas-Matti Soikkeli wrote:
Good day.
I'm building on Jenkins 2.0 with pipelines and jenkinsfiles from SCM
to achieve continuous delivery for my project.
However I'm facing issues with groovy workflow to source my
environment variables for ansible.
I'm running Ansible from source so I need to run:
|
$ source ansible/hacking/env-setup
|
However when I run this in my Jenkinsfile:
|
stage "deploy"
sh 'source /opt/ansible/hacking/env-setup"
sh 'ansible --version'
|
My environent variables from env-setup are gone. How would one include
envs from setup script to env.PATH?
env-setup setups python dependencies and correct paths. You can check
out the environment script from:
https://raw.githubusercontent.com/ansible/ansible/devel/hacking/env-setup
Any hints how to work out this?
Best regards, t-m
--
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
<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/457a6cf4-2f48-4711-bea8-e48227f9ac3d%40googlegroups.com
<https://groups.google.com/d/msgid/jenkinsci-users/457a6cf4-2f48-4711-bea8-e48227f9ac3d%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
*Eric Pyle
*
Release Engineer
Lebanon
+1 603-277-3060 (T)
+1 603-359-8670 (M)
eric.p...@cd-adapco.com <mailto:eric.p...@cd-adapco.com>
http://www.cd-adapco.com <http://www.cd-adapco.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/68ddc53a-70b1-78ca-fe4d-c34faa87b68c%40cd-adapco.com.
For more options, visit https://groups.google.com/d/optout.