Skip to content

Commit ce18c6f

Browse files
Bot Updating Templated Files
1 parent 045043d commit ce18c6f

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
@@ -77,6 +77,7 @@ pipeline {
7777
script{
7878
env.EXIT_STATUS = ''
7979
env.CI_TEST_ATTEMPTED = ''
80+
env.PUSH_ATTEMPTED = ''
8081
env.LS_RELEASE = sh(
8182
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:fedora-i3 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8283
returnStdout: true).trim()
@@ -862,6 +863,9 @@ pipeline {
862863
environment name: 'EXIT_STATUS', value: ''
863864
}
864865
steps {
866+
script{
867+
env.PUSH_ATTEMPTED = 'true'
868+
}
865869
retry_backoff(5,5) {
866870
sh '''#! /bin/bash
867871
set -e
@@ -891,11 +895,18 @@ pipeline {
891895
environment name: 'EXIT_STATUS', value: ''
892896
}
893897
steps {
898+
script{
899+
env.PUSH_ATTEMPTED = 'true'
900+
}
894901
retry_backoff(5,5) {
895902
sh '''#! /bin/bash
896903
set -e
897904
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
898-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
905+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
906+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
907+
else
908+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
909+
fi
899910
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
900911
for i in "${CACHE[@]}"; do
901912
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1063,7 +1074,7 @@ EOF
10631074
}
10641075
script {
10651076
if (env.GITHUBIMAGE =~ /lspipepr/){
1066-
if (env.CI_TEST_ATTEMPTED == "true"){
1077+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
10671078
sh '''#! /bin/bash
10681079
# Function to retrieve JSON data from URL
10691080
get_json() {
@@ -1124,14 +1135,21 @@ EOF
11241135
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11251136
-H "Accept: application/vnd.github.v3+json" \
11261137
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1127-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1138+
-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}\\"}"
11281139
else
11291140
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11301141
-H "Accept: application/vnd.github.v3+json" \
11311142
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1132-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1143+
-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}\\`\\"}"
11331144
fi
11341145
'''
1146+
} else {
1147+
sh '''#! /bin/bash
1148+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1149+
-H "Accept: application/vnd.github.v3+json" \
1150+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1151+
-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.\\"}"
1152+
'''
11351153
}
11361154
}
11371155
}

0 commit comments

Comments
 (0)