Skip to content

Commit 66da21d

Browse files
Bot Updating Templated Files
1 parent b8bcdc4 commit 66da21d

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
@@ -39,10 +39,11 @@ pipeline {
3939
// Setup all the basic environment variables needed for the build
4040
stage("Set ENV Variables base"){
4141
steps{
42+
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
4243
script{
4344
env.EXIT_STATUS = ''
4445
env.LS_RELEASE = sh(
45-
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' || : ''',
46+
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' || : ''',
4647
returnStdout: true).trim()
4748
env.LS_RELEASE_NOTES = sh(
4849
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' ''',
@@ -228,7 +229,7 @@ pipeline {
228229
script{
229230
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
230231
}
231-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
232+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
232233
sh '''#! /bin/bash
233234
docker run --rm \
234235
-v ${WORKSPACE}:/mnt \
@@ -376,6 +377,26 @@ pipeline {
376377
}
377378
}
378379
}
380+
// If this is a master build check the S6 service file perms
381+
stage("Check S6 Service file Permissions"){
382+
when {
383+
branch "master"
384+
environment name: 'CHANGE_ID', value: ''
385+
environment name: 'EXIT_STATUS', value: ''
386+
}
387+
steps {
388+
script{
389+
sh '''#! /bin/bash
390+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
391+
if [[ -n "${WRONG_PERM}" ]]; then
392+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
393+
exit 1
394+
else
395+
echo "S6 service file perms look good."
396+
fi '''
397+
}
398+
}
399+
}
379400
/* #######################
380401
GitLab Mirroring
381402
####################### */
@@ -668,6 +689,7 @@ pipeline {
668689
]) {
669690
script{
670691
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
692+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
671693
}
672694
sh '''#! /bin/bash
673695
set -e
@@ -694,8 +716,6 @@ pipeline {
694716
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
695717
-e WEB_AUTH=\"${CI_AUTH}\" \
696718
-e WEB_PATH=\"${CI_WEBPATH}\" \
697-
-e DO_REGION="ams3" \
698-
-e DO_BUCKET="lsio-ci" \
699719
-t ghcr.io/linuxserver/ci:latest \
700720
python3 test_build.py'''
701721
}
@@ -949,8 +969,67 @@ pipeline {
949969
environment name: 'EXIT_STATUS', value: ''
950970
}
951971
steps {
952-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
953-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
972+
sh '''#! /bin/bash
973+
# Function to retrieve JSON data from URL
974+
get_json() {
975+
local url="$1"
976+
local response=$(curl -s "$url")
977+
if [ $? -ne 0 ]; then
978+
echo "Failed to retrieve JSON data from $url"
979+
return 1
980+
fi
981+
local json=$(echo "$response" | jq .)
982+
if [ $? -ne 0 ]; then
983+
echo "Failed to parse JSON data from $url"
984+
return 1
985+
fi
986+
echo "$json"
987+
}
988+
989+
build_table() {
990+
local data="$1"
991+
992+
# Get the keys in the JSON data
993+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
994+
995+
# Check if keys are empty
996+
if [ -z "$keys" ]; then
997+
echo "JSON report data does not contain any keys or the report does not exist."
998+
return 1
999+
fi
1000+
1001+
# Build table header
1002+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1003+
1004+
# Loop through the JSON data to build the table rows
1005+
local rows=""
1006+
for build in $keys; do
1007+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1008+
if [ "$status" = "true" ]; then
1009+
status="✅"
1010+
else
1011+
status="❌"
1012+
fi
1013+
local row="| "$build" | "$status" |\\n"
1014+
rows="${rows}${row}"
1015+
done
1016+
1017+
local table="${header}${rows}"
1018+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1019+
echo "$escaped_table"
1020+
}
1021+
1022+
# Retrieve JSON data from URL
1023+
data=$(get_json "$CI_JSON_URL")
1024+
# Create table from JSON data
1025+
table=$(build_table "$data")
1026+
echo -e "$table"
1027+
1028+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1029+
-H "Accept: application/vnd.github.v3+json" \
1030+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1031+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
1032+
9541033
}
9551034
}
9561035
}

0 commit comments

Comments
 (0)