groovy split() on User ID

19 views
Skip to first unread message

krish

unread,
Jul 24, 2019, 1:20:23 PM7/24/19
to Jenkins Users
Hello, 

Anyone tried using the split for sending out the emails for approval to multiple recipients.

In My Jenkinsfile i have something like this 

Jenkinsfile:

Approvals = $SPACE == 'stage' ? '1234, 4567' : $SPACE == 'prod' ? '8912,3455'   

Assume these numbers as UserID.

Groovy code:

config.Approvals.split(,).each {


}

help me to work this out.

thanks
Krish

Slide

unread,
Jul 24, 2019, 1:34:35 PM7/24/19
to Jenkins User Mailing List
You aren't actually using any variables in your mail call since you have no $ inside the string. Generally, when using each, I like to specify the iterator variable name (it defaults to 'it').

Approvals.each { id ->

    mail(to: "${id}@domain.com")

}

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/68b15761-0abe-4899-ab29-7612e8c27b5b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages