如何配置jenkins发送gitlab提交消息?

时间:2019-05-15 14:43:48

标签: git jenkins gitlab

我想在jenkins中提取git commit消息,并通过jenkins发送的电子邮件将其发送以成功构建。

根据搜索,Git changelog插件可用于此目的。但是我不确定我们应该如何配置它。任何带有例子的答案都会帮助我。

我在jenkins中添加了Git changelog插件。尝试了很少的设置,但没有一个起作用。

2 个答案:

答案 0 :(得分:0)

您可以在变量中获取消息,然后可以使用如下所示的条件通过邮件发送消息:-

stage('Git Commit Message') {
    agent { node { label 'Linux' } }
        steps {
            script {
                result = sh (script: "git log --format=%B -n 1 COMMIT_ID", returnStdout: true)
                // After this you can put condition for if your build is scccessful and send "result" variable in mail
            }
        }
    }

答案 1 :(得分:0)

post {
        always {
            mail bcc: '', body: "A commit has been done \n
            status : $ {currentBuild.currentResult}: \n Job 
            {env.JOb_NAME}\n build
                    ${enb.BUILD_NUMBER} \n for detail: ${env.BUILD_URL}\n 
            Any action?",
                    cc: '', from: '', replyTo: '', subject: "Report 
             ${env.BUILD_ID}", to: 'johnsmith@abc.com'
    }
相关问题