[workflow plugin] inject environment variables or using parameters to prepare the run

983 views
Skip to first unread message

Christoph Vogtländer

unread,
Feb 5, 2015, 4:30:11 AM2/5/15
to Jenkinsci Users
Hi,

I want to use the workflow plugin and together with the "Prepare an
environment for the run" feature provided by the EnvInject plug in.
Unfortunately, when setting key/value pairs the variables are not
available in the "env" workflow variable.
Parameters (Dynamic Parameter Plug-in) will not show up either. Please
note that this is not related to JENKINS-26050, I want to configure
parameters in the project itself and not triggering it from another job.

What I want to achieve is to have a common workflow stored in the SCM
(Groovy CPD DSL from SCM). Different workflow jobs should all use the
common workflow and be able to control behaviour (like checkout branch).

The only solution I can think of is to use "Groovy CPD DSL" (without
SCM), defining the variables I want and then using a workflow global
library from the internal Git repository. I would like to avoid that
because the workflow is for a specific task (e.g. nightly build) and
does not really belong in a global library. Maybe just a question of the
abstraction level... and personal preference.

Are there other possible solutions?

Christoph

Timur Batyrshin

unread,
Feb 9, 2015, 10:28:25 AM2/9/15
to jenkins...@googlegroups.com, jen...@mockies.de
Hi Christoph,

I use the plain Jenkins parameters for that, (checkmark for "This build is parameterized").
The parameters passed then appear inside the Groovy script as variables but not environment values.
If you need to set env value you can do the following inside your Groovy script:

env.MY_VAR = MY_VAR


Regards,
Timur

четверг, 5 февраля 2015 г., 12:30:11 UTC+3 пользователь Christoph Vogtländer написал:

Jesse Glick

unread,
Feb 25, 2015, 6:22:57 PM2/25/15
to jenkins...@googlegroups.com, jen...@mockies.de
On Thursday, February 5, 2015 at 4:30:11 AM UTC-5, Christoph Vogtländer wrote:
I want to use the workflow plugin and together with the "Prepare an
environment for the run" feature provided by the EnvInject plug in.

EnvInject is probably useless for Workflow.

Are there other possible solutions?

In Jenkins Enterprise by CloudBees this would be handled by a Workflow job template.

Yes you can use job parameters with default values for this purpose as Timur noted, but then you cannot have plain old Build Now, only Build with Parameters.

Martin d'Anjou

unread,
Oct 23, 2015, 1:19:54 PM10/23/15
to Jenkins Users, jen...@mockies.de
On Wednesday, February 25, 2015 at 6:22:57 PM UTC-5, Jesse Glick wrote:
On Thursday, February 5, 2015 at 4:30:11 AM UTC-5, Christoph Vogtländer wrote:
I want to use the workflow plugin and together with the "Prepare an
environment for the run" feature provided by the EnvInject plug in.

EnvInject is probably useless for Workflow.


I find envinject useful. I use it to inject the cause of the build into the build phase, so I can set the build description to something meaningful to my users. My users like to know who triggered a build by looking at the build history. When I tried that with Workflow, it did not work. Is there a way to access the build cause(s) in a workflow?
Reply all
Reply to author
Forward
0 new messages