Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Commit 7fbe228

Browse files
Bot Updating Templated Files
1 parent 78276b7 commit 7fbe228

File tree

1 file changed

+85
-6
lines changed

1 file changed

+85
-6
lines changed

Jenkinsfile

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ pipeline {
3333
// Setup all the basic environment variables needed for the build
3434
stage("Set ENV Variables base"){
3535
steps{
36+
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
3637
script{
3738
env.EXIT_STATUS = ''
3839
env.LS_RELEASE = sh(
39-
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' || : ''',
40+
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' || : ''',
4041
returnStdout: true).trim()
4142
env.LS_RELEASE_NOTES = sh(
4243
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' ''',
@@ -220,7 +221,7 @@ pipeline {
220221
script{
221222
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
222223
}
223-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
224+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
224225
sh '''#! /bin/bash
225226
docker run --rm \
226227
-v ${WORKSPACE}:/mnt \
@@ -347,6 +348,26 @@ pipeline {
347348
}
348349
}
349350
}
351+
// If this is a master build check the S6 service file perms
352+
stage("Check S6 Service file Permissions"){
353+
when {
354+
branch "master"
355+
environment name: 'CHANGE_ID', value: ''
356+
environment name: 'EXIT_STATUS', value: ''
357+
}
358+
steps {
359+
script{
360+
sh '''#! /bin/bash
361+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
362+
if [[ -n "${WRONG_PERM}" ]]; then
363+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
364+
exit 1
365+
else
366+
echo "S6 service file perms look good."
367+
fi '''
368+
}
369+
}
370+
}
350371
/* #######################
351372
GitLab Mirroring
352373
####################### */
@@ -639,6 +660,7 @@ pipeline {
639660
]) {
640661
script{
641662
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
663+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
642664
}
643665
sh '''#! /bin/bash
644666
set -e
@@ -665,8 +687,6 @@ pipeline {
665687
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
666688
-e WEB_AUTH=\"${CI_AUTH}\" \
667689
-e WEB_PATH=\"${CI_WEBPATH}\" \
668-
-e DO_REGION="ams3" \
669-
-e DO_BUCKET="lsio-ci" \
670690
-t ghcr.io/linuxserver/ci:latest \
671691
python3 test_build.py'''
672692
}
@@ -920,8 +940,67 @@ pipeline {
920940
environment name: 'EXIT_STATUS', value: ''
921941
}
922942
steps {
923-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
924-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
943+
sh '''#! /bin/bash
944+
# Function to retrieve JSON data from URL
945+
get_json() {
946+
local url="$1"
947+
local response=$(curl -s "$url")
948+
if [ $? -ne 0 ]; then
949+
echo "Failed to retrieve JSON data from $url"
950+
return 1
951+
fi
952+
local json=$(echo "$response" | jq .)
953+
if [ $? -ne 0 ]; then
954+
echo "Failed to parse JSON data from $url"
955+
return 1
956+
fi
957+
echo "$json"
958+
}
959+
960+
build_table() {
961+
local data="$1"
962+
963+
# Get the keys in the JSON data
964+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
965+
966+
# Check if keys are empty
967+
if [ -z "$keys" ]; then
968+
echo "JSON report data does not contain any keys or the report does not exist."
969+
return 1
970+
fi
971+
972+
# Build table header
973+
local header="| Tag | Passed |\\n| --- | --- |\\n"
974+
975+
# Loop through the JSON data to build the table rows
976+
local rows=""
977+
for build in $keys; do
978+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
979+
if [ "$status" = "true" ]; then
980+
status="✅"
981+
else
982+
status="❌"
983+
fi
984+
local row="| "$build" | "$status" |\\n"
985+
rows="${rows}${row}"
986+
done
987+
988+
local table="${header}${rows}"
989+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
990+
echo "$escaped_table"
991+
}
992+
993+
# Retrieve JSON data from URL
994+
data=$(get_json "$CI_JSON_URL")
995+
# Create table from JSON data
996+
table=$(build_table "$data")
997+
echo -e "$table"
998+
999+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1000+
-H "Accept: application/vnd.github.v3+json" \
1001+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1002+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
1003+
9251004
}
9261005
}
9271006
}

0 commit comments

Comments
 (0)