Skip to content

Commit 0008cf6

Browse files
Bot Updating Templated Files
1 parent 4ef8a79 commit 0008cf6

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}:arch-i3 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8283
returnStdout: true).trim()
@@ -864,6 +865,9 @@ pipeline {
864865
environment name: 'EXIT_STATUS', value: ''
865866
}
866867
steps {
868+
script{
869+
env.PUSH_ATTEMPTED = 'true'
870+
}
867871
retry_backoff(5,5) {
868872
sh '''#! /bin/bash
869873
set -e
@@ -893,11 +897,18 @@ pipeline {
893897
environment name: 'EXIT_STATUS', value: ''
894898
}
895899
steps {
900+
script{
901+
env.PUSH_ATTEMPTED = 'true'
902+
}
896903
retry_backoff(5,5) {
897904
sh '''#! /bin/bash
898905
set -e
899906
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
900-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
907+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
908+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
909+
else
910+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
911+
fi
901912
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
902913
for i in "${CACHE[@]}"; do
903914
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1065,7 +1076,7 @@ EOF
10651076
}
10661077
script {
10671078
if (env.GITHUBIMAGE =~ /lspipepr/){
1068-
if (env.CI_TEST_ATTEMPTED == "true"){
1079+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
10691080
sh '''#! /bin/bash
10701081
# Function to retrieve JSON data from URL
10711082
get_json() {
@@ -1126,14 +1137,21 @@ EOF
11261137
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11271138
-H "Accept: application/vnd.github.v3+json" \
11281139
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1129-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1140+
-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}\\"}"
11301141
else
11311142
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11321143
-H "Accept: application/vnd.github.v3+json" \
11331144
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1134-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1145+
-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}\\`\\"}"
11351146
fi
11361147
'''
1148+
} else {
1149+
sh '''#! /bin/bash
1150+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1151+
-H "Accept: application/vnd.github.v3+json" \
1152+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1153+
-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.\\"}"
1154+
'''
11371155
}
11381156
}
11391157
}

0 commit comments

Comments
 (0)