Skip to content

Commit 8e764f1

Browse files
committed
Post PR comment when build fails early
1 parent 07c2352 commit 8e764f1

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Jenkinsfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,13 @@ EOF
11601160
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR for commit ${COMMIT_SHA:0:7} : \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
11611161
fi
11621162
'''
1163+
} else {
1164+
sh '''#! /bin/bash
1165+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1166+
-H "Accept: application/vnd.github.v3+json" \
1167+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1168+
-d "{\\"body\\": \\"I am a bot, the build for PR commit ${COMMIT_SHA:0:7} failed and as a result no CI test was attempted and no images were pushed.\\"}"
1169+
'''
11631170
}
11641171
}
11651172
}

ansible/roles/repository/templates/Jenkinsfile.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,13 @@ EOF
15921592
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR for commit ${COMMIT_SHA:0:7} : \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
15931593
fi
15941594
'''
1595+
} else {
1596+
sh '''#! /bin/bash
1597+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1598+
-H "Accept: application/vnd.github.v3+json" \
1599+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1600+
-d "{\\"body\\": \\"I am a bot, the build for PR commit ${COMMIT_SHA:0:7} failed and as a result no CI test was attempted and no images were pushed.\\"}"
1601+
'''
15951602
}
15961603
}
15971604
}

0 commit comments

Comments
 (0)