0

我希望发送一封关于失败和/或所有阶段及其状态的列表的电子邮件。我已将我的代码包装在 try{} 中,并且正在捕获任何失败。在我的控制台输出中,它说电子邮件已发送到适当的电子邮件,但我没有收到它...在我的 Jenkins 配置下,我已经设置了我的 Jenkins 位置、电子邮件通知和扩展电子邮件通知设置。我已确认电子邮件通知正常工作,并将相同的凭据添加到扩展电子邮件通知中。这是我的控制台输出:

Running on Dobby in D:Pipelinefolder
[Pipeline] {
[Pipeline] emailext
Sending email to: myemail@school.edu
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] checkout

Results (nunit3) saved as TestResult.xml
[Pipeline] }
[Pipeline] // stage
[Pipeline] emailext
Sending email to: myemail@school.edu
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

请在下面查看我的代码:

node('Dobby') {
try {
    notifyBuild('STARTED')

stage('Checkout') {
checkout([$class: 'SubversionSCM',
    additionalCredentials: [], 
    excludedCommitMessages: '', 
    excludedRegions: '', 
    excludedRevprop: '', 
    excludedUsers: 'buildbot', 
    filterChangelog: false, 
    ignoreDirPropChanges: false, 
    includedRegions: '', 
    locations: [[credentialsId: 'aPpr0pR1at3.CrDEnt1Al5.83', 
        depthOption: 'infinity', 
        ignoreExternalsOption: true, 
        local: '.', 
        remote: "http://jenkins.svn.link.edu/svn/my/repo"]],
    workspaceUpdater: [$class: 'UpdateUpdater']])
}

stage('Build webApp') {          
bat 'C:/"Program Files (x86)/Microsoft Visual Studio"/2017/Community/MSBuild/15.0/Bin/MSBuild.exe webApp/webApp.sln  /m /p:VisualStudioVersion=15.0'   //msbuild     
}

stage('Test: Check if IIS webApp ON') {
bat 'C:/"Program Files (x86)"/NUnit.org/nunit-console/nunit3-console.exe SeleniumNunit/SeleniumNunit/bin/Debug/SeleniumNunit.dll'
}

} catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
throw e
} finally {
// Success or failure, always send notifications
notifyBuild(currentBuild.result)
}
} 

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

emailext(
  to: 'myemail@school.edu',
  subject: "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
  body: "details",
  recipientProviders: [[$class: 'DevelopersRecipientProvider']]
)
}

您能找出我没有收到电子邮件的任何原因吗?

4

1 回答 1

1

所以...我取消选中扩展电子邮件通知下的使用 SMTP 身份验证,它起作用了!我现在需要解决这个问题...

于 2017-09-12T15:32:00.047 回答