Skip to content

Commit 81b7a89

Browse files
Bot Updating Templated Files
1 parent 4cfef53 commit 81b7a89

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()
@@ -929,6 +930,9 @@ pipeline {
929930
environment name: 'EXIT_STATUS', value: ''
930931
}
931932
steps {
933+
script{
934+
env.PUSH_ATTEMPTED = 'true'
935+
}
932936
retry_backoff(5,5) {
933937
sh '''#! /bin/bash
934938
set -e
@@ -958,11 +962,18 @@ pipeline {
958962
environment name: 'EXIT_STATUS', value: ''
959963
}
960964
steps {
965+
script{
966+
env.PUSH_ATTEMPTED = 'true'
967+
}
961968
retry_backoff(5,5) {
962969
sh '''#! /bin/bash
963970
set -e
964971
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
965-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
972+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
973+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
974+
else
975+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
976+
fi
966977
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
967978
for i in "${CACHE[@]}"; do
968979
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1130,7 +1141,7 @@ EOF
11301141
}
11311142
script {
11321143
if (env.GITHUBIMAGE =~ /lspipepr/){
1133-
if (env.CI_TEST_ATTEMPTED == "true"){
1144+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11341145
sh '''#! /bin/bash
11351146
# Function to retrieve JSON data from URL
11361147
get_json() {
@@ -1191,14 +1202,21 @@ EOF
11911202
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11921203
-H "Accept: application/vnd.github.v3+json" \
11931204
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1194-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1205+
-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}\\"}"
11951206
else
11961207
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11971208
-H "Accept: application/vnd.github.v3+json" \
11981209
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1199-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1210+
-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}\\`\\"}"
12001211
fi
12011212
'''
1213+
} else {
1214+
sh '''#! /bin/bash
1215+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1216+
-H "Accept: application/vnd.github.v3+json" \
1217+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1218+
-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.\\"}"
1219+
'''
12021220
}
12031221
}
12041222
}

0 commit comments

Comments
 (0)