login Signup

How do I create an approver list for a manual task in DSL

With DSL, I'm trying to create a manual task in my pipeline stage.

The list of approvers is comma separated string. The following code does not work. The UI shows the list of approvers to be empty (except if I enter only 1 user or group) and at runtime, no email is sent and nobody can approve that manual task.

 def approverList=input.split(",")
 stage("myStage") {
     task ("stage Promotion") {
           beforeTask = null
           taskType = 'MANUAL'
           notificationTemplate = 'my_pipeline_promotion_template'
           instruction = "Please approve so that this pipeline may continue."
           approver = approverList

What am I doing wrong?

avatar image By lrochette 6k asked Jun 24, 2016 at 01:27 PM
more ▼
(comments are locked)
10|750 characters needed characters left

1 answer: sort voted first

Directly assigning the output of split() will indeed error out; turns out the issue is that split returns a string [] while the DSL is specifically expecting a list. The two look the same when printed out, but are not interchangeable types.

tokenize() rather than split() returns a list, though be aware that these methods behave differently as noted in this article. The 3 samples below will work:

 approver = input.tokenize(",")


Alternatively we can stick with split() and convert the output to a list this way:

 approver = input.split(",") as Set

or you can construct your array manually:

 input.split(",").each {
   approverList << it 
avatar image By lrochette 6k answered Jun 24, 2016 at 01:34 PM
more ▼
(comments are locked)
10|750 characters needed characters left
Your answer
toggle preview:

Up to 8 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.