Skip to content

Commit 09ac9e9

Browse files
Bot Updating Templated Files
1 parent 7e3c008 commit 09ac9e9

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
@@ -78,6 +78,7 @@ pipeline {
7878
script{
7979
env.EXIT_STATUS = ''
8080
env.CI_TEST_ATTEMPTED = ''
81+
env.PUSH_ATTEMPTED = ''
8182
env.LS_RELEASE = sh(
8283
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' || : ''',
8384
returnStdout: true).trim()
@@ -937,6 +938,9 @@ pipeline {
937938
environment name: 'EXIT_STATUS', value: ''
938939
}
939940
steps {
941+
script{
942+
env.PUSH_ATTEMPTED = 'true'
943+
}
940944
retry_backoff(5,5) {
941945
sh '''#! /bin/bash
942946
set -e
@@ -966,11 +970,18 @@ pipeline {
966970
environment name: 'EXIT_STATUS', value: ''
967971
}
968972
steps {
973+
script{
974+
env.PUSH_ATTEMPTED = 'true'
975+
}
969976
retry_backoff(5,5) {
970977
sh '''#! /bin/bash
971978
set -e
972979
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
973-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
980+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
981+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
982+
else
983+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
984+
fi
974985
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
975986
for i in "${CACHE[@]}"; do
976987
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1142,7 +1153,7 @@ EOF
11421153
}
11431154
script {
11441155
if (env.GITHUBIMAGE =~ /lspipepr/){
1145-
if (env.CI_TEST_ATTEMPTED == "true"){
1156+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11461157
sh '''#! /bin/bash
11471158
# Function to retrieve JSON data from URL
11481159
get_json() {
@@ -1203,14 +1214,21 @@ EOF
12031214
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
12041215
-H "Accept: application/vnd.github.v3+json" \
12051216
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1206-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1217+
-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}\\"}"
12071218
else
12081219
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
12091220
-H "Accept: application/vnd.github.v3+json" \
12101221
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1211-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1222+
-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}\\`\\"}"
12121223
fi
12131224
'''
1225+
} else {
1226+
sh '''#! /bin/bash
1227+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1228+
-H "Accept: application/vnd.github.v3+json" \
1229+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1230+
-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.\\"}"
1231+
'''
12141232
}
12151233
}
12161234
}

0 commit comments

Comments
 (0)