Skip to content

Commit aa5bc6a

Browse files
Bot Updating Templated Files
1 parent 1ec5ca5 commit aa5bc6a

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}:latest 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8283
returnStdout: true).trim()
@@ -925,6 +926,9 @@ pipeline {
925926
environment name: 'EXIT_STATUS', value: ''
926927
}
927928
steps {
929+
script{
930+
env.PUSH_ATTEMPTED = 'true'
931+
}
928932
retry_backoff(5,5) {
929933
sh '''#! /bin/bash
930934
set -e
@@ -954,11 +958,18 @@ pipeline {
954958
environment name: 'EXIT_STATUS', value: ''
955959
}
956960
steps {
961+
script{
962+
env.PUSH_ATTEMPTED = 'true'
963+
}
957964
retry_backoff(5,5) {
958965
sh '''#! /bin/bash
959966
set -e
960967
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
961-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
968+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
969+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
970+
else
971+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
972+
fi
962973
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
963974
for i in "${CACHE[@]}"; do
964975
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1126,7 +1137,7 @@ EOF
11261137
}
11271138
script {
11281139
if (env.GITHUBIMAGE =~ /lspipepr/){
1129-
if (env.CI_TEST_ATTEMPTED == "true"){
1140+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11301141
sh '''#! /bin/bash
11311142
# Function to retrieve JSON data from URL
11321143
get_json() {
@@ -1187,14 +1198,21 @@ EOF
11871198
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11881199
-H "Accept: application/vnd.github.v3+json" \
11891200
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1190-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1201+
-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}\\"}"
11911202
else
11921203
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11931204
-H "Accept: application/vnd.github.v3+json" \
11941205
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1195-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1206+
-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}\\`\\"}"
11961207
fi
11971208
'''
1209+
} else {
1210+
sh '''#! /bin/bash
1211+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1212+
-H "Accept: application/vnd.github.v3+json" \
1213+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1214+
-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.\\"}"
1215+
'''
11981216
}
11991217
}
12001218
}

0 commit comments

Comments
 (0)