Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2807 from forslund/test/jenkins-update-comment
Browse files Browse the repository at this point in the history
Add update comment logic to Jenkins
  • Loading branch information
krisgesling authored Jul 14, 2021
2 parents 31e1e2d + e0489a8 commit d1816f5
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d1816f5

Please sign in to comment.