Parametrized MultiBranch Pipeline Jobs?

36 views
Skip to first unread message

Michael Lasevich

unread,
Aug 26, 2016, 3:52:49 PM8/26/16
to Jenkins Users
Is it possible to add parameters to a multibranch pipeline job? 

I am happy with the job running with some sorts of default values when running automatically, but it would be nice to be able to have Jenkinsfile  (or even manually) define parameters that could be optionally provided when running the job manually.

Thanks,

-M


Michael Lasevich

unread,
Aug 26, 2016, 7:17:33 PM8/26/16
to Jenkins Users
In case anyone is searching here is my own answer to this question - there is a 'parameter' command in the Pipeline DSL designed for this exact purpose, but there are some gitcha's

* First, the code generator generates broken code - so do not trust it. Luckily main issue is easy to fix by replacing the "parameter [...]" syntax with "parameter([...])" syntax - but there are other issues - so doublecheck

* Then there is the fact that the request for parameters is set from the job itself, so essentially you are setting parameters for the NEXT job, not for the one that is running. This actually makes sense, once you wrap your head around it

* Ans this is a very nasty one - if you make a mistake in your parameter() call that leads to invalid  config (for example a Choice parameter with no choices) you are in trouble. Because to fix it, you have to run a job and the job will not run until you fix the problem. I ended up having to delete the entire MB job to fix it.

-M

Jesse Glick

unread,
Aug 30, 2016, 5:18:01 AM8/30/16
to Jenkins Users
The first issue is being fixed.

The second issue has a possible resolution filed in JIRA.

The third issue certainly sounds like a bug. Please file it in `workflow-multibranch-plugin` with a script to demonstrate how to reproduce.

Jesse Glick

unread,
Aug 30, 2016, 5:20:37 AM8/30/16
to Jenkins Users
BTW I think you are referring to the `properties` step, which takes a list of properties, one of which may be parameter definitions.
Reply all
Reply to author
Forward
0 new messages