Define parameters for a group of jobs

31 views
Skip to first unread message

francesco desposito

unread,
Feb 11, 2017, 5:43:26 AM2/11/17
to Jenkins Users
Hello,
I want to group the jobs referring to a single project together. 
Then I would like to define some parameters at group level and I want that those parameters are automatically passed to the jobs belonging to that group.
For example I want to create a group P1 with jobs a1, b1, c1. Then I define a parameter x for P1. I would like that x is automatically defined for the jobs a1, b1, c1.

Is that possible?

Thanks 

Richard Ginga

unread,
Feb 13, 2017, 11:11:27 AM2/13/17
to jenkins...@googlegroups.com
Francesco, there are actually many ways to do this.

1. use Pipeline script or System groovy build step or post build - "trigger parameterized  builds on other projects" to pass in parameter x

2. with system groovy script, you can create/update a global variable that all builds will see

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/22d8816b-881c-48b6-be2b-f031e9b2ee48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dick Ginga
Build Engineer

David Karr

unread,
Feb 13, 2017, 6:06:47 PM2/13/17
to Jenkins Users
On Monday, February 13, 2017 at 8:11:27 AM UTC-8, Richard Ginga wrote:
Francesco, there are actually many ways to do this.

1. use Pipeline script or System groovy build step or post build - "trigger parameterized  builds on other projects" to pass in parameter x

2. with system groovy script, you can create/update a global variable that all builds will see

On Sat, Feb 11, 2017 at 5:43 AM, francesco desposito <francesco.d...@gmail.com> wrote:
Hello,
I want to group the jobs referring to a single project together. 
Then I would like to define some parameters at group level and I want that those parameters are automatically passed to the jobs belonging to that group.
For example I want to create a group P1 with jobs a1, b1, c1. Then I define a parameter x for P1. I would like that x is automatically defined for the jobs a1, b1, c1.

Is that possible?

Thanks 


I understood the OP's request, which I've often wanted myself, and I don't see how either of those strategies would do what he wants.  I think you misunderstood what he's asking.

Let's say you have ten related jobs in a "project", all of which are parameterized, and all of which take a "Foo" parameter, a "Bar" parameter, and a "Something" parameter. He wants the ability to define in a single place that all of these jobs should expect the "Foo", "Bar", and "Something" parameters, instead of creating each one manually in each of the ten projects, copying the default value (if any) and description from the first one.

Richard Ginga

unread,
Feb 13, 2017, 6:15:54 PM2/13/17
to jenkins...@googlegroups.com
ok, I almost added "based on the information provided" so I may have misunderstood. #2 might still work unless you and he wanted to be able to run any of the jobs independently and provide unique parameter values at that time. if not, you would have to change each of your jobs to use a system global variable defined in the System Configuration and then one job to set them.

--
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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

francesco desposito

unread,
Feb 14, 2017, 8:35:33 AM2/14/17
to Jenkins Users
Thanks for your answers.
I'm going to try to use the system global variables as Richard suggested.


Il giorno martedì 14 febbraio 2017 00:15:54 UTC+1, Richard Ginga ha scritto:
ok, I almost added "based on the information provided" so I may have misunderstood. #2 might still work unless you and he wanted to be able to run any of the jobs independently and provide unique parameter values at that time. if not, you would have to change each of your jobs to use a system global variable defined in the System Configuration and then one job to set them.
On Mon, Feb 13, 2017 at 6:06 PM, David Karr <davidmic...@gmail.com> wrote:
On Monday, February 13, 2017 at 8:11:27 AM UTC-8, Richard Ginga wrote:
Francesco, there are actually many ways to do this.

1. use Pipeline script or System groovy build step or post build - "trigger parameterized  builds on other projects" to pass in parameter x

2. with system groovy script, you can create/update a global variable that all builds will see

On Sat, Feb 11, 2017 at 5:43 AM, francesco desposito <francesco.d...@gmail.com> wrote:
Hello,
I want to group the jobs referring to a single project together. 
Then I would like to define some parameters at group level and I want that those parameters are automatically passed to the jobs belonging to that group.
For example I want to create a group P1 with jobs a1, b1, c1. Then I define a parameter x for P1. I would like that x is automatically defined for the jobs a1, b1, c1.

Is that possible?

Thanks 


I understood the OP's request, which I've often wanted myself, and I don't see how either of those strategies would do what he wants.  I think you misunderstood what he's asking.

Let's say you have ten related jobs in a "project", all of which are parameterized, and all of which take a "Foo" parameter, a "Bar" parameter, and a "Something" parameter. He wants the ability to define in a single place that all of these jobs should expect the "Foo", "Bar", and "Something" parameters, instead of creating each one manually in each of the ten projects, copying the default value (if any) and description from the first one.

--
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.

Richard Ginga

unread,
Feb 14, 2017, 8:56:59 AM2/14/17
to jenkins...@googlegroups.com
here is a code snippet we run from a post-build groovy step (which you could use instead of the build groovy step)

def globalProps = manager.hudson.getGlobalNodeProperties()
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

props[0].envVars.put( manager.envVars["YourVariableName, value])


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/61a19e90-75cb-4982-8145-7a428b02b634%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Richard Ginga

unread,
Feb 14, 2017, 8:59:40 AM2/14/17
to jenkins...@googlegroups.com
correction, this needs to be run from a post-build groovy step because the variable "manager" is predefined there

On Tue, Feb 14, 2017 at 8:56 AM, Richard Ginga <rgi...@disruptorbeam.com> wrote:
here is a code snippet we run from a post-build groovy step (which you could use instead of the build groovy step)

def globalProps = manager.hudson.getGlobalNodeProperties()
def props = globalProps.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)

props[0].envVars.put( manager.envVars["YourVariableName, value])

Reply all
Reply to author
Forward
0 new messages