Skip to content

Commit 128bbc5

Browse files
Bot Updating Templated Files
1 parent d2818d6 commit 128bbc5

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
@@ -70,6 +70,7 @@ pipeline {
7070
script{
7171
env.EXIT_STATUS = ''
7272
env.CI_TEST_ATTEMPTED = ''
73+
env.PUSH_ATTEMPTED = ''
7374
env.LS_RELEASE = sh(
7475
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' || : ''',
7576
returnStdout: true).trim()
@@ -853,6 +854,9 @@ pipeline {
853854
environment name: 'EXIT_STATUS', value: ''
854855
}
855856
steps {
857+
script{
858+
env.PUSH_ATTEMPTED = 'true'
859+
}
856860
retry_backoff(5,5) {
857861
sh '''#! /bin/bash
858862
set -e
@@ -882,11 +886,18 @@ pipeline {
882886
environment name: 'EXIT_STATUS', value: ''
883887
}
884888
steps {
889+
script{
890+
env.PUSH_ATTEMPTED = 'true'
891+
}
885892
retry_backoff(5,5) {
886893
sh '''#! /bin/bash
887894
set -e
888895
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
889-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
896+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
897+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
898+
else
899+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
900+
fi
890901
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
891902
for i in "${CACHE[@]}"; do
892903
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1054,7 +1065,7 @@ EOF
10541065
}
10551066
script {
10561067
if (env.GITHUBIMAGE =~ /lspipepr/){
1057-
if (env.CI_TEST_ATTEMPTED == "true"){
1068+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
10581069
sh '''#! /bin/bash
10591070
# Function to retrieve JSON data from URL
10601071
get_json() {
@@ -1115,14 +1126,21 @@ EOF
11151126
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11161127
-H "Accept: application/vnd.github.v3+json" \
11171128
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1118-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1129+
-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}\\"}"
11191130
else
11201131
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
11211132
-H "Accept: application/vnd.github.v3+json" \
11221133
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1123-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1134+
-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}\\`\\"}"
11241135
fi
11251136
'''
1137+
} else {
1138+
sh '''#! /bin/bash
1139+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1140+
-H "Accept: application/vnd.github.v3+json" \
1141+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1142+
-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.\\"}"
1143+
'''
11261144
}
11271145
}
11281146
}

0 commit comments

Comments
 (0)