How to set programmatically recipients of Jenkins Email-ext plugin?

前端 未结 2 1415
情话喂你
情话喂你 2021-01-16 13:01

I\'m trying to set the recipients of the Email-ext (aka Editable Email Notficiation) to the owners of failed tests. Since the owners can\'t be calc

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-16 13:20

    If you need to read list of recipients from file on remote agent, expand above answer with FilePath:

    import javax.mail.Message
    import javax.mail.internet.InternetAddress
    
    fp = new FilePath(build.workspace, build.workspace.toString() + "/recipients.txt")
    emails = fp.readToString().split("\n")
    
    for (email in emails) {
        msg.addRecipient(Message.RecipientType.TO, new InternetAddress(email))
    }
    

提交回复
热议问题