我目前有此发布操作,可以通过电子邮件通知我詹金斯构建成功:
post {
always {
emailext body: "${env.SITE} was deployed to ${DEPLOY_TO} with the following results: ${currentBuild.currentResult} ", subject: "Deployment results for ${env.SITE}", to: 'user@host.com,user2@host.com'
}
}
}
一旦在存储库中进行了新的提交,就会触发生成,因此我想知道如何包括所有更改的行的提交哈希,提交消息以及提交差异。我真的不知道我能在电子邮件中得到多少详细信息。我还没有找到任何可以让我从网上开始的东西。预先感谢您的帮助!
答案 0 :(得分:0)
您可以使用last changes plugin,一旦安装了插件,就可以使用以下管道代码片段发送带有差异的电子邮件:
pipeline {
agent any
stages {
stage('send html diff') {
steps {
git 'https://github.com/YOUR_REPO.git'
script {
def publisher = LastChanges.getLastChangesPublisher "PREVIOUS_REVISION", "SIDE", "LINE", true, true, "", "", "", "", ""
publisher.publishLastChanges()
def htmlDiff = publisher.getHtmlDiff()
writeFile file: 'build-diff.html', text: htmlDiff
emailext (
subject: "Jenkins - changes of ${env.JOB_NAME} #${env.BUILD_NUMBER}",
attachmentsPattern: '**/*build-diff.html',
mimeType: 'text/html',
body: """<p>See attached diff of build <b>${env.JOB_NAME} #${env.BUILD_NUMBER}</b>.</p>
<p>Check build changes on Jenkins <b><a href="${env.BUILD_URL}/last-changes">here</a></b>.</p>""",
to: "YOUR-EMAIL@gmail.com" )
} //end script
}
}
}
}
有一节介绍如何在plugin docs here上将差异作为电子邮件发送。