Skip to content

Commit 27d5c55

Browse files
Bot Updating Templated Files
1 parent c60725b commit 27d5c55

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}:3.22 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8182
returnStdout: true).trim()
@@ -859,6 +860,9 @@ pipeline {
859860
environment name: 'EXIT_STATUS', value: ''
860861
}
861862
steps {
863+
script{
864+
env.PUSH_ATTEMPTED = 'true'
865+
}
862866
retry_backoff(5,5) {
863867
sh '''#! /bin/bash
864868
set -e
@@ -888,11 +892,18 @@ pipeline {
888892
environment name: 'EXIT_STATUS', value: ''
889893
}
890894
steps {
895+
script{
896+
env.PUSH_ATTEMPTED = 'true'
897+
}
891898
retry_backoff(5,5) {
892899
sh '''#! /bin/bash
893900
set -e
894901
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
895-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
902+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
903+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
904+
else
905+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
906+
fi
896907
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
897908
for i in "${CACHE[@]}"; do
898909
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1060,7 +1071,7 @@ EOF
10601071
}
10611072
script {
10621073
if (env.GITHUBIMAGE =~ /lspipepr/){
1063-
if (env.CI_TEST_ATTEMPTED == "true"){
1074+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
10641075
sh '''#! /bin/bash
10651076
# Function to retrieve JSON data from URL
10661077
get_json() {
@@ -1121,14 +1132,21 @@ EOF
11211132
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11221133
-H "Accept: application/vnd.github.v3+json" \
11231134
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1124-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1135+
-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}\\"}"
11251136
else
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 is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1140+
-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}\\`\\"}"
11301141
fi
11311142
'''
1143+
} else {
1144+
sh '''#! /bin/bash
1145+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1146+
-H "Accept: application/vnd.github.v3+json" \
1147+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1148+
-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.\\"}"
1149+
'''
11321150
}
11331151
}
11341152
}

0 commit comments

Comments
 (0)