2

젠킨스는 GitHub으로 푸시 한 후 모든 프로젝트를 자동으로 빌드하므로 Jenkins가 빌드가 성공했는지 여부를 알리는 전자 메일 알림을 보내고 싶습니다. 빌드 pipline. 나는 두 recipientProviders을 정의Jenkins 파이프 라인의 업스트림 커미터에게 알림 전자 메일 보내기

#!/usr/bin/env groovy 

def call(String buildStatus = 'STARTED') { 
    // build status of null means successful 
    buildStatus = buildStatus ?: 'SUCCESS' 

    // Default values 
    def subject = "JENKINS-NOTIFICATION: ${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" 
    def details = """<p>${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p> 
    <p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>""" 

    // Send email to user who has started the build 
    emailext(
     subject: subject, 
     body: details, 
     attachLog: true, 
     compressLog: true, 
     recipientProviders: [[$class: 'RequesterRecipientProvider'], [$class:'UpstreamComitterRecipientProvider']] 
    ) 
} 

참고 :

나는 다음과 같은 스크립트 공유 라이브러리를 만들었습니다. 내가 아는 한 RequesterRecipientProvider은 Jenkins에서 직접 빌드를 트리거 한 사람에게 전자 메일을 보내야하며 UpstreamComitterRecipientProvider은 빌드를 트리거 한 마지막 자식 커밋을 한 사람에게 전자 메일을 보내야합니다. Jenkinsfile에서 ( source)

을 나는 라이브러리를로드 나는 jenkinsfile의 후 블록에서 sendNotification에 명령을 정의 :

#!groovy 
@Library('[email protected]') _ 

pipeline { 
    agent any 
    stages{ 
     stage('Checkout code base'){ 
      steps{ 
       checkout scm 
      } 
     } 
     stage('do something'){ 
      steps{ 
       sh "do something" 
      } 
     } 
     stage('do something'){ 
      steps{ 
       sh "do something" 
      } 
     } 
    } 
    post{ 
     always{ 
      sendNotifications currentBuild.result 
     } 
    } 
} 
내가 수동으로 젠킨스에서 빌드를 실행할 때

이제 전자 메일 알림이 도착 ,하지만 내가 GitHub을 밀고 Jenkins 빌드가 실행되면 아무 이메일 알림도 보내지지 않습니다. 이것은 파이프 라인의 로그입니다 :

messageContentType = text/html; charset=UTF-8 
Request made to attach build log 
Request made to compress build log 
Adding recipients from project recipient list 
Sending email to upstream committer(s). 
Adding recipients from trigger recipient list 
Successfully created MimeMessage 
An attempt to send an e-mail to empty list of recipients, ignored. 
Some error occured trying to send the email...check the Jenkins log 

불행히도, Jenkins 로그에는 더 이상의 정보가 없습니다. UpstreamComitterRecipientProvider은 마지막 커미터의 전자 메일 주소를 제공하지 않습니다.

저는 프로젝트의 커밋 내역에있는 모든 개발자에게 전자 메일을 보내는 DevelopersRecipientProvider을 사용하려고했습니다. 이것은 잘 작동합니다. 불행히도 UpstreamComitterRecipientProvider은 그렇지 않습니다.

비슷한 문제가 발생 했습니까? 내가 놓친 게 있니?

의견을 보내 주시면 감사하겠습니다.

답변

0

당신이 실제로 CulpritsRecipientProvider 또는 DevelopersRecipientProvider가 UpstreamComitterRecipientProvider를 원하는 것처럼 들리는 사운드는 현재가 아닌 업스트림 빌드를 봅니다.

+0

CulpritsRecipientProvider와 함께 사용하십시오! 감사. – fgk

관련 문제