Skip to content

Commit a674110

Browse files
Bot Updating Templated Files
1 parent 0a43190 commit a674110

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
@@ -78,6 +78,7 @@ pipeline {
7878
script{
7979
env.EXIT_STATUS = ''
8080
env.CI_TEST_ATTEMPTED = ''
81+
env.PUSH_ATTEMPTED = ''
8182
env.LS_RELEASE = sh(
8283
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' || : ''',
8384
returnStdout: true).trim()
@@ -927,6 +928,9 @@ pipeline {
927928
environment name: 'EXIT_STATUS', value: ''
928929
}
929930
steps {
931+
script{
932+
env.PUSH_ATTEMPTED = 'true'
933+
}
930934
retry_backoff(5,5) {
931935
sh '''#! /bin/bash
932936
set -e
@@ -956,11 +960,18 @@ pipeline {
956960
environment name: 'EXIT_STATUS', value: ''
957961
}
958962
steps {
963+
script{
964+
env.PUSH_ATTEMPTED = 'true'
965+
}
959966
retry_backoff(5,5) {
960967
sh '''#! /bin/bash
961968
set -e
962969
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
963-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
970+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
971+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
972+
else
973+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
974+
fi
964975
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
965976
for i in "${CACHE[@]}"; do
966977
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1128,7 +1139,7 @@ EOF
11281139
}
11291140
script {
11301141
if (env.GITHUBIMAGE =~ /lspipepr/){
1131-
if (env.CI_TEST_ATTEMPTED == "true"){
1142+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
11321143
sh '''#! /bin/bash
11331144
# Function to retrieve JSON data from URL
11341145
get_json() {
@@ -1189,14 +1200,21 @@ EOF
11891200
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11901201
-H "Accept: application/vnd.github.v3+json" \
11911202
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1192-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1203+
-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}\\"}"
11931204
else
11941205
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11951206
-H "Accept: application/vnd.github.v3+json" \
11961207
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1197-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1208+
-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}\\`\\"}"
11981209
fi
11991210
'''
1211+
} else {
1212+
sh '''#! /bin/bash
1213+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1214+
-H "Accept: application/vnd.github.v3+json" \
1215+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1216+
-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.\\"}"
1217+
'''
12001218
}
12011219
}
12021220
}

0 commit comments

Comments
 (0)