How to configure Jenkins to send encrypted emails with gpg?

允我心安 提交于 2019-12-08 05:40:27

问题


I am looking for instructions on how to configure the jenkins email plugin (ext-mail) to encrypt notifications? The uncle google did not help me too much.


回答1:


such feature is not out-of-box, you need custom ExtendedEmailPublisher for your needs.

        MimeMessage msg = createMail(mailType, build, listener);
        Address[] allRecipients = msg.getAllRecipients();
        if (allRecipients != null) {
            StringBuilder buf = new StringBuilder("Sending email to:");
            for (Address a : allRecipients) {
                buf.append(' ').append(a);
            }
            listener.getLogger().println(buf);
            Transport.send(msg);
            if (build.getAction(MailMessageIdAction.class) == null) {
                build.addAction(new MailMessageIdAction(msg.getMessageID()));
            }
            return true;
        }

you can get Recipients and Email message for sign/encrypt and call Transport.send(msg) at last.



来源:https://stackoverflow.com/questions/12154558/how-to-configure-jenkins-to-send-encrypted-emails-with-gpg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!