workflow plugin start parameterized job

54 views
Skip to first unread message

Eric Engel

unread,
Nov 20, 2014, 1:01:07 PM11/20/14
to jenkins...@googlegroups.com
Resending with correct subject

-----Ursprüngliche Nachricht-----
Von: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] Im Auftrag von Eric Engel
Gesendet: Donnerstag, 20. November 2014 16:33
An: jenkins...@googlegroups.com
Betreff: AW: Last Success shows unexpected time

Hello Jenkins Users,

we want to try the new jenkins workflow-plugin. Is there any documentation besides the information from github https://github.com/jenkinsci/workflow-plugin ?
Especially a simple question: How to start a parameterized job? Ideally with all parameters from the parent job.

Regards,
Eric

--
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.
For more options, visit https://groups.google.com/d/optout.

James Nord

unread,
Nov 24, 2014, 7:10:42 AM11/24/14
to jenkins...@googlegroups.com, e...@ivu.de
Hi Eric

the syntax is something like

ArrayList<ParameterValue> yourparamaters=new ArrayList<ParameterValue>();
yourparamaters.add(new hudson.model.StringParameterValue('PARAM','123'));

build  job: 'yourJobNameToBuild', parameters: yourparamaters

you can also shorthand this if you don't need to re-use the same parameters

build  job: 'yourJobNameToBuild', parameters: [new hudson.model.StringParameterValue('PARAM1','123'), new hudson.model.StringParameterValue('PARAM2','345')]

The next thing you need is the list of parameters the workflow was invoked with - 
(I am guessing from scanning the source - so may not be 100% correct) 

The parameters are all exposed to the to the workflow as variables
so parameter "BOB" with value "TrueGent" can be accessed as BOB
e.g.
  echo "the value of BOB is " + BOB

if you don't actually know what parameters you want (ie you want all of them) then I think you need to retreive them programatically (I don't beleive they are injected as a list of paramatervalues - or a map by default - so you may require a custom step implementation - however I'm sure someone will pipe up with a quick and easy way to do it.

/James




However - I would caution against using the workflow to trigger other jobs if you can - It's ideal is to self contain the workflow and steps in a single place so you don't have configuration sprawl (the workflow and all the configuration of it is defined in one single place).

/James
Reply all
Reply to author
Forward
0 new messages