admin管理员组

文章数量:1559748

文章目录

    • 腾讯企业邮箱设置
    • jenkins
      • 1. 安装Email Extension Plugin
      • 2. 配置管理员邮箱
      • 3. 配置smtp验证
      • 4. 通过pipeline发送邮件
        • 1. declarative pipeline
        • 2. 脚本方式
    • 更多

构建时可能出现错误,想着jenkins可以发送邮件。通常情况下,仓库的维护者或负责代码的开发者接受这个邮件。这篇文章记录下如何将邮件群发到腾讯企业邮箱。

腾讯企业邮箱设置

jenkins

1. 安装Email Extension Plugin

2. 配置管理员邮箱

系统配置-> Jenkins Location

管理员邮箱将作为发送人

3. 配置smtp验证

一般你需要选择一个smtp服务器,负责发送你的邮件。

选择 系统配置->Extended E-mail Notification

4. 通过pipeline发送邮件

1. declarative pipeline
pipeline {
    agent any
    environment {
        GIT_URL = "http://sample.git"
        MAINTAINER = "zhangsan,lisi"
    }
    stages {
        stage('Hello') {
            steps {
                sh 'exit 1'
            }
            
        }
    }
    post{
        failure {    
                 // @qq是你配的默认后缀名,会自动加上去
                 // 这样配置会群发给zhangsan@qq lisi@qq
                 emailext body: "hello", subject: 'world', to: "${MAINTAINER}"
         }
    }
}

2. 脚本方式
pipeline {
    agent any
    environment {
        GIT_URL = "http://sample.git"
        MAINTAINER = "zhangsan,lisi"
    }
    stages {
        stage('Hello') {
            steps {
                sh 'exit 1'
            }
            
        }
    }
    post{
        failure {    
        		script {
        		    // 这里需要什么内容自己去拼字符串,subject是主题,body是内容,                 
        		    // to是邮件列表,","分割
                    def hello = "hello world"
                 	emailext body: "$hello", subject: 'world', to: "${MAINTAINER}"
                 }
        }
    }
}

上面两种方式你都可以收到"hello world"

更多

你可以编写自己的邮件模板,

官方文档参考意义不大:

https://plugins.jenkins.io/email-ext/

我找了一个能用的:

https://blog.csdn/weixin_33694620/article/details/92637403

本文标签: 腾讯企业邮箱方式JenkinsEmail