Skip to content

Commit e2590af

Browse files
Bot Updating Templated Files
1 parent bd42052 commit e2590af

File tree

1 file changed

+88
-6
lines changed

1 file changed

+88
-6
lines changed

Jenkinsfile

+88-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ pipeline {
4242
// Setup all the basic environment variables needed for the build
4343
stage("Set ENV Variables base"){
4444
steps{
45+
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
4546
script{
4647
env.EXIT_STATUS = ''
4748
env.LS_RELEASE = sh(
48-
script: '''docker run --rm ghcr.io/linuxserver/alexeiled-skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
49+
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' || : ''',
4950
returnStdout: true).trim()
5051
env.LS_RELEASE_NOTES = sh(
5152
script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''',
@@ -232,7 +233,7 @@ pipeline {
232233
script{
233234
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
234235
}
235-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
236+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
236237
sh '''#! /bin/bash
237238
docker run --rm \
238239
-v ${WORKSPACE}:/mnt \
@@ -380,6 +381,26 @@ pipeline {
380381
}
381382
}
382383
}
384+
// If this is a master build check the S6 service file perms
385+
stage("Check S6 Service file Permissions"){
386+
when {
387+
branch "master"
388+
environment name: 'CHANGE_ID', value: ''
389+
environment name: 'EXIT_STATUS', value: ''
390+
}
391+
steps {
392+
script{
393+
sh '''#! /bin/bash
394+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
395+
if [[ -n "${WRONG_PERM}" ]]; then
396+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
397+
exit 1
398+
else
399+
echo "S6 service file perms look good."
400+
fi '''
401+
}
402+
}
403+
}
383404
/* #######################
384405
GitLab Mirroring
385406
####################### */
@@ -637,6 +658,7 @@ pipeline {
637658
]) {
638659
script{
639660
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
661+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
640662
}
641663
sh '''#! /bin/bash
642664
set -e
@@ -661,8 +683,6 @@ pipeline {
661683
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
662684
-e WEB_AUTH=\"${CI_AUTH}\" \
663685
-e WEB_PATH=\"${CI_WEBPATH}\" \
664-
-e DO_REGION="ams3" \
665-
-e DO_BUCKET="lsio-ci" \
666686
-t ghcr.io/linuxserver/ci:latest \
667687
python3 test_build.py'''
668688
}
@@ -796,6 +816,9 @@ pipeline {
796816
docker manifest create ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER}
797817
docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} --os linux --arch arm64 --variant v8
798818
fi
819+
docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest || :
820+
docker manifest create ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:amd64-latest
821+
docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest
799822
docker manifest push --purge ${MANIFESTIMAGE}:latest
800823
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG}
801824
docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG}
@@ -897,8 +920,67 @@ pipeline {
897920
environment name: 'EXIT_STATUS', value: ''
898921
}
899922
steps {
900-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
901-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
923+
sh '''#! /bin/bash
924+
# Function to retrieve JSON data from URL
925+
get_json() {
926+
local url="$1"
927+
local response=$(curl -s "$url")
928+
if [ $? -ne 0 ]; then
929+
echo "Failed to retrieve JSON data from $url"
930+
return 1
931+
fi
932+
local json=$(echo "$response" | jq .)
933+
if [ $? -ne 0 ]; then
934+
echo "Failed to parse JSON data from $url"
935+
return 1
936+
fi
937+
echo "$json"
938+
}
939+
940+
build_table() {
941+
local data="$1"
942+
943+
# Get the keys in the JSON data
944+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
945+
946+
# Check if keys are empty
947+
if [ -z "$keys" ]; then
948+
echo "JSON report data does not contain any keys or the report does not exist."
949+
return 1
950+
fi
951+
952+
# Build table header
953+
local header="| Tag | Passed |\\n| --- | --- |\\n"
954+
955+
# Loop through the JSON data to build the table rows
956+
local rows=""
957+
for build in $keys; do
958+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
959+
if [ "$status" = "true" ]; then
960+
status="✅"
961+
else
962+
status="❌"
963+
fi
964+
local row="| "$build" | "$status" |\\n"
965+
rows="${rows}${row}"
966+
done
967+
968+
local table="${header}${rows}"
969+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
970+
echo "$escaped_table"
971+
}
972+
973+
# Retrieve JSON data from URL
974+
data=$(get_json "$CI_JSON_URL")
975+
# Create table from JSON data
976+
table=$(build_table "$data")
977+
echo -e "$table"
978+
979+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
980+
-H "Accept: application/vnd.github.v3+json" \
981+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
982+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
983+
902984
}
903985
}
904986
}

0 commit comments

Comments
 (0)