Skip to content

Commit b8ae91c

Browse files
Bot Updating Templated Files
1 parent 0efec86 commit b8ae91c

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
@@ -76,6 +76,7 @@ pipeline {
7676
script{
7777
env.EXIT_STATUS = ''
7878
env.CI_TEST_ATTEMPTED = ''
79+
env.PUSH_ATTEMPTED = ''
7980
env.LS_RELEASE = sh(
8081
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:alpine322 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8182
returnStdout: true).trim()
@@ -860,6 +861,9 @@ pipeline {
860861
environment name: 'EXIT_STATUS', value: ''
861862
}
862863
steps {
864+
script{
865+
env.PUSH_ATTEMPTED = 'true'
866+
}
863867
retry_backoff(5,5) {
864868
sh '''#! /bin/bash
865869
set -e
@@ -889,11 +893,18 @@ pipeline {
889893
environment name: 'EXIT_STATUS', value: ''
890894
}
891895
steps {
896+
script{
897+
env.PUSH_ATTEMPTED = 'true'
898+
}
892899
retry_backoff(5,5) {
893900
sh '''#! /bin/bash
894901
set -e
895902
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
896-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
903+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
904+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
905+
else
906+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
907+
fi
897908
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
898909
for i in "${CACHE[@]}"; do
899910
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1061,7 +1072,7 @@ EOF
10611072
}
10621073
script {
10631074
if (env.GITHUBIMAGE =~ /lspipepr/){
1064-
if (env.CI_TEST_ATTEMPTED == "true"){
1075+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
10651076
sh '''#! /bin/bash
10661077
# Function to retrieve JSON data from URL
10671078
get_json() {
@@ -1122,14 +1133,21 @@ EOF
11221133
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11231134
-H "Accept: application/vnd.github.v3+json" \
11241135
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1125-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1136+
-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}\\"}"
11261137
else
11271138
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11281139
-H "Accept: application/vnd.github.v3+json" \
11291140
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1130-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1141+
-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}\\`\\"}"
11311142
fi
11321143
'''
1144+
} else {
1145+
sh '''#! /bin/bash
1146+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1147+
-H "Accept: application/vnd.github.v3+json" \
1148+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1149+
-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.\\"}"
1150+
'''
11331151
}
11341152
}
11351153
}

0 commit comments

Comments
 (0)