Skip to content

Commit b7f3fe8

Browse files
Bot Updating Templated Files
1 parent 871d078 commit b7f3fe8

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
@@ -79,6 +79,7 @@ pipeline {
7979
script{
8080
env.EXIT_STATUS = ''
8181
env.CI_TEST_ATTEMPTED = ''
82+
env.PUSH_ATTEMPTED = ''
8283
env.LS_RELEASE = sh(
8384
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' || : ''',
8485
returnStdout: true).trim()
@@ -1007,6 +1008,9 @@ pipeline {
10071008
environment name: 'EXIT_STATUS', value: ''
10081009
}
10091010
steps {
1011+
script{
1012+
env.PUSH_ATTEMPTED = 'true'
1013+
}
10101014
retry_backoff(5,5) {
10111015
sh '''#! /bin/bash
10121016
set -e
@@ -1036,11 +1040,18 @@ pipeline {
10361040
environment name: 'EXIT_STATUS', value: ''
10371041
}
10381042
steps {
1043+
script{
1044+
env.PUSH_ATTEMPTED = 'true'
1045+
}
10391046
retry_backoff(5,5) {
10401047
sh '''#! /bin/bash
10411048
set -e
10421049
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
1043-
[[ ${MANIFESTIMAGE%%/*} =~ \\. ]] && MANIFESTIMAGEPLUS="${MANIFESTIMAGE}" || MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
1050+
if [[ "${MANIFESTIMAGE%%/*}" =~ \\. ]]; then
1051+
MANIFESTIMAGEPLUS="${MANIFESTIMAGE}"
1052+
else
1053+
MANIFESTIMAGEPLUS="docker.io/${MANIFESTIMAGE}"
1054+
fi
10441055
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
10451056
for i in "${CACHE[@]}"; do
10461057
if [[ "${MANIFESTIMAGEPLUS}" == "$(cut -d "/" -f1 <<< ${i})"* ]]; then
@@ -1212,7 +1223,7 @@ EOF
12121223
}
12131224
script {
12141225
if (env.GITHUBIMAGE =~ /lspipepr/){
1215-
if (env.CI_TEST_ATTEMPTED == "true"){
1226+
if (env.CI_TEST_ATTEMPTED == "true" || env.PUSH_ATTEMPTED == "true"){
12161227
sh '''#! /bin/bash
12171228
# Function to retrieve JSON data from URL
12181229
get_json() {
@@ -1273,14 +1284,21 @@ EOF
12731284
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
12741285
-H "Accept: application/vnd.github.v3+json" \
12751286
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1276-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1287+
-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}\\"}"
12771288
else
12781289
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
12791290
-H "Accept: application/vnd.github.v3+json" \
12801291
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1281-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1292+
-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}\\`\\"}"
12821293
fi
12831294
'''
1295+
} else {
1296+
sh '''#! /bin/bash
1297+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1298+
-H "Accept: application/vnd.github.v3+json" \
1299+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1300+
-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.\\"}"
1301+
'''
12841302
}
12851303
}
12861304
}

0 commit comments

Comments
 (0)