Skip to content

Commit 0b348a9

Browse files
Bot Updating Templated Files
1 parent b7c16db commit 0b348a9

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()
@@ -928,6 +929,9 @@ pipeline {
928929
environment name: 'EXIT_STATUS', value: ''
929930
}
930931
steps {
932+
script{
933+
env.PUSH_ATTEMPTED = 'true'
934+
}
931935
retry_backoff(5,5) {
932936
sh '''#! /bin/bash
933937
set -e
@@ -957,11 +961,18 @@ pipeline {
957961
environment name: 'EXIT_STATUS', value: ''
958962
}
959963
steps {
964+
script{
965+
env.PUSH_ATTEMPTED = 'true'
966+
}
960967
retry_backoff(5,5) {
961968
sh '''#! /bin/bash
962969
set -e
963970
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
964-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
971+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
972+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
973+
else
974+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
975+
fi
965976
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
966977
for i in "${CACHE[@]}"; do
967978
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1129,7 +1140,7 @@ EOF
11291140
}
11301141
script {
11311142
if (env.GITHUBIMAGE =~ /lspipepr/){
1132-
if (env.CI_TEST_ATTEMPTED == "true"){
1143+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11331144
sh '''#! /bin/bash
11341145
# Function to retrieve JSON data from URL
11351146
get_json() {
@@ -1190,14 +1201,21 @@ EOF
11901201
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11911202
-H "Accept: application/vnd.github.v3+json" \
11921203
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1193-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1204+
-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}\\"}"
11941205
else
11951206
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11961207
-H "Accept: application/vnd.github.v3+json" \
11971208
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1198-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1209+
-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}\\`\\"}"
11991210
fi
12001211
'''
1212+
} else {
1213+
sh '''#! /bin/bash
1214+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1215+
-H "Accept: application/vnd.github.v3+json" \
1216+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1217+
-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.\\"}"
1218+
'''
12011219
}
12021220
}
12031221
}

0 commit comments

Comments
 (0)