Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Commit 3f6eb18

Browse files
Bot Updating Templated Files
1 parent 2a90b20 commit 3f6eb18

File tree

1 file changed

+88
-6
lines changed

1 file changed

+88
-6
lines changed

Jenkinsfile

Lines changed: 88 additions & 6 deletions
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' ''',
@@ -238,7 +239,7 @@ pipeline {
238239
script{
239240
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
240241
}
241-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
242+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
242243
sh '''#! /bin/bash
243244
docker run --rm \
244245
-v ${WORKSPACE}:/mnt \
@@ -386,6 +387,26 @@ pipeline {
386387
}
387388
}
388389
}
390+
// If this is a master build check the S6 service file perms
391+
stage("Check S6 Service file Permissions"){
392+
when {
393+
branch "master"
394+
environment name: 'CHANGE_ID', value: ''
395+
environment name: 'EXIT_STATUS', value: ''
396+
}
397+
steps {
398+
script{
399+
sh '''#! /bin/bash
400+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
401+
if [[ -n "${WRONG_PERM}" ]]; then
402+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
403+
exit 1
404+
else
405+
echo "S6 service file perms look good."
406+
fi '''
407+
}
408+
}
409+
}
389410
/* #######################
390411
GitLab Mirroring
391412
####################### */
@@ -643,6 +664,7 @@ pipeline {
643664
]) {
644665
script{
645666
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
667+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
646668
}
647669
sh '''#! /bin/bash
648670
set -e
@@ -667,8 +689,6 @@ pipeline {
667689
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
668690
-e WEB_AUTH=\"${CI_AUTH}\" \
669691
-e WEB_PATH=\"${CI_WEBPATH}\" \
670-
-e DO_REGION="ams3" \
671-
-e DO_BUCKET="lsio-ci" \
672692
-t ghcr.io/linuxserver/ci:latest \
673693
python3 test_build.py'''
674694
}
@@ -802,6 +822,9 @@ pipeline {
802822
docker manifest create ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER}
803823
docker manifest annotate ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} --os linux --arch arm64 --variant v8
804824
fi
825+
docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest || :
826+
docker manifest create ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:amd64-latest
827+
docker manifest push --purge ${MANIFESTIMAGE}:arm32v7-latest
805828
docker manifest push --purge ${MANIFESTIMAGE}:latest
806829
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG}
807830
docker manifest push --purge ${MANIFESTIMAGE}:${EXT_RELEASE_TAG}
@@ -903,8 +926,67 @@ pipeline {
903926
environment name: 'EXIT_STATUS', value: ''
904927
}
905928
steps {
906-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
907-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
929+
sh '''#! /bin/bash
930+
# Function to retrieve JSON data from URL
931+
get_json() {
932+
local url="$1"
933+
local response=$(curl -s "$url")
934+
if [ $? -ne 0 ]; then
935+
echo "Failed to retrieve JSON data from $url"
936+
return 1
937+
fi
938+
local json=$(echo "$response" | jq .)
939+
if [ $? -ne 0 ]; then
940+
echo "Failed to parse JSON data from $url"
941+
return 1
942+
fi
943+
echo "$json"
944+
}
945+
946+
build_table() {
947+
local data="$1"
948+
949+
# Get the keys in the JSON data
950+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
951+
952+
# Check if keys are empty
953+
if [ -z "$keys" ]; then
954+
echo "JSON report data does not contain any keys or the report does not exist."
955+
return 1
956+
fi
957+
958+
# Build table header
959+
local header="| Tag | Passed |\\n| --- | --- |\\n"
960+
961+
# Loop through the JSON data to build the table rows
962+
local rows=""
963+
for build in $keys; do
964+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
965+
if [ "$status" = "true" ]; then
966+
status="✅"
967+
else
968+
status="❌"
969+
fi
970+
local row="| "$build" | "$status" |\\n"
971+
rows="${rows}${row}"
972+
done
973+
974+
local table="${header}${rows}"
975+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
976+
echo "$escaped_table"
977+
}
978+
979+
# Retrieve JSON data from URL
980+
data=$(get_json "$CI_JSON_URL")
981+
# Create table from JSON data
982+
table=$(build_table "$data")
983+
echo -e "$table"
984+
985+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
986+
-H "Accept: application/vnd.github.v3+json" \
987+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
988+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
989+
908990
}
909991
}
910992
}

0 commit comments

Comments
 (0)