Skip to content

Commit 7739d5a

Browse files
Bot Updating Templated Files
1 parent aefdbab commit 7739d5a

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

Jenkinsfile

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pipeline {
7979
script{
8080
env.EXIT_STATUS = ''
8181
env.CI_TEST_ATTEMPTED = ''
82+
env.PUSH_ATTEMPTED = ''
8283
env.LS_RELEASE = sh(
8384
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:latest 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8485
returnStdout: true).trim()
@@ -935,6 +936,9 @@ pipeline {
935936
environment name: 'EXIT_STATUS', value: ''
936937
}
937938
steps {
939+
script{
940+
env.PUSH_ATTEMPTED = 'true'
941+
}
938942
retry_backoff(5,5) {
939943
sh '''#! /bin/bash
940944
set -e
@@ -964,11 +968,18 @@ pipeline {
964968
environment name: 'EXIT_STATUS', value: ''
965969
}
966970
steps {
971+
script{
972+
env.PUSH_ATTEMPTED = 'true'
973+
}
967974
retry_backoff(5,5) {
968975
sh '''#! /bin/bash
969976
set -e
970977
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
971-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
978+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
979+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
980+
else
981+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
982+
fi
972983
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
973984
for i in "${CACHE[@]}"; do
974985
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1136,7 +1147,7 @@ EOF
11361147
}
11371148
script {
11381149
if (env.GITHUBIMAGE =~ /lspipepr/){
1139-
if (env.CI_TEST_ATTEMPTED == "true"){
1150+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11401151
sh '''#! /bin/bash
11411152
# Function to retrieve JSON data from URL
11421153
get_json() {
@@ -1197,14 +1208,21 @@ EOF
11971208
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11981209
-H "Accept: application/vnd.github.v3+json" \
11991210
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1200-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1211+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR for commit ${COMMIT_SHA:0:7} : \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
12011212
else
12021213
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
12031214
-H "Accept: application/vnd.github.v3+json" \
12041215
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1205-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1216+
-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}\\`\\"}"
12061217
fi
12071218
'''
1219+
} else {
1220+
sh '''#! /bin/bash
1221+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1222+
-H "Accept: application/vnd.github.v3+json" \
1223+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1224+
-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.\\"}"
1225+
'''
12081226
}
12091227
}
12101228
}

0 commit comments

Comments
 (0)