Merge pull request #2807 from forslund/test/jenkins-update-comment

Add update comment logic to Jenkins
pull/2954/head
Kris Gesling 2021-07-14 09:43:49 +09:30 committed by GitHub
commit d1816f5933
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 10 deletions

54
Jenkinsfile vendored
View File

@ -120,16 +120,33 @@ pipeline {
}
failure {
script {
def comment_text = 'Voight Kampff Integration Test Failed ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + ')). ' +
'\nMycroft logs are also available: ' +
'[skills.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/skills.log), ' +
'[audio.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/audio.log), ' +
'[voice.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/voice.log), ' +
'[bus.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/bus.log), ' +
'[enclosure.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/enclosure.log)'
// Create comment for Pull Requests
if (env.CHANGE_ID) {
echo 'Sending PR comment'
pullRequest.comment('Voight Kampff Integration Test Failed ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + ')). ' +
'\nMycroft logs are also available: ' +
'[skills.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/skills.log), ' +
'[audio.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/audio.log), ' +
'[voice.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/voice.log), ' +
'[bus.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/bus.log), ' +
'[enclosure.log](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '/logs/enclosure.log)')
def found_comment = false
for (comment in pullRequest.comments) {
echo "Author: ${comment.user}"
if (comment.user == "devops-mycroft" &&
comment.body.contains("Voight Kampff")) {
echo "Updating comment..."
found_comment = true
pullRequest.editComment(
comment.id,
comment_text
)
}
}
if (!found_comment) {
echo 'Sending PR comment'
pullRequest.comment(comment_text)
}
}
}
// Send failure email containing a link to the Jenkins build
@ -184,8 +201,25 @@ pipeline {
success {
script {
if (env.CHANGE_ID) {
echo 'Sending PR comment'
pullRequest.comment('Voight Kampff Integration Test Succeeded ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))')
def comment_text = 'Voight Kampff Integration Test Succeeded ([Results](https://reports.mycroft.ai/core/' + env.BRANCH_ALIAS + '))'
def found_comment = false
for (comment in pullRequest.comments) {
echo "Author: ${comment.user}"
if (comment.user == "devops-mycroft" &&
comment.body.contains("Voight Kampff")) {
echo "Updating comment!"
found_comment = true
pullRequest.editComment(
comment.id,
comment_text
)
break
}
}
if (!found_comment) {
echo 'Sending PR comment'
pullRequest.comment(comment_text)
}
}
}
// Send success email containing a link to the Jenkins build