How can I set the Sender's address in Jenkins?

后端 未结 6 892
心在旅途
心在旅途 2021-01-30 19:16

I\'m sending mail from Jenkins to an anonymous SMTP relay internally. That relay then securely sends mail to exchange online via TLS on port 587. The transport works perfectly,

相关标签:
6条回答
  • 2021-01-30 19:35

    Jenkins uses the System Admin e-mail address as the sender address for e-mail notification. You can configure this under Manage Jenkins -> Configure System. This is under the Jenkins Location header on that page! It is not immediately obvious that this setting is tied to the e-mail notification settings, since it is not under the E-mail notification header on the configuration page.

    0 讨论(0)
  • 2021-01-30 19:37

    Manage Jenkins -> Configure System -> Jenkins Location -> System Admin e-mail address

    You can search the page for "Jenkins Location" to change the default value of address not configured yet to whatever you want.

    0 讨论(0)
  • 2021-01-30 19:41

    I'm not sure if it is what you meant, but Jenkins enables you to provide a full Sender E-mail Address for notifications. Go to Manage jenkins, then System configuration and find section called E-mail Notification.

    You can provide you email address in a form of Jenkins <foo@mycompany.com>.

    0 讨论(0)
  • 2021-01-30 19:42

    There are two places to add the "E-Mail Notificaitons"

    1. Global level
    2. Local level (Jenkins job level)

    To set the E-Mail Notification at Global Level, follow below steps - 1) Go to Manage Jenkins 2) Configure System 3) Jenkins Location 4) System Admin e-mail address

    To set the E-Mail Notification at local level (per Jenkins job level), follow below steps - 1) Click on the Job name (if existing one) 2) click on the "Configure" 3) Then look for the "Post-build Action" 4) Specify the email address under "E-mail Notification". 5) Save the changes.

    0 讨论(0)
  • 2021-01-30 19:54

    If you need to do this without using the jenkins UI (for instance in automating a jenkins setup) - you can do so with a groovy script.

    import jenkins.model.*
    
    def jenkinsLocationConfiguration = JenkinsLocationConfiguration.get()
    
    jenkinsLocationConfiguration.setAdminAddress("[your admin name] <[your admin email address]>")
    // example format -> .setAdminAddress("Jane Doe <foo@company_email.com>")    
    
    jenkinsLocationConfiguration.save()
    

    Do note: I did not write this script (although I have tested it and it works), all credit to Peter Halliday and his website with other helpful groovy scripts here.

    0 讨论(0)
  • 2021-01-30 19:54
    import javax.mail.Message.RecipientType
    import javax.mail.Address
    import javax.mail.internet.InternetAddress
    import javax.mail.internet.MimeMessage
    
    msg.setFrom(new InternetAddress("john...@server.com"))
    
    0 讨论(0)
提交回复
热议问题