@@ -42,10 +42,11 @@ pipeline {
42
42
// Setup all the basic environment variables needed for the build
43
43
stage(" Set ENV Variables base" ){
44
44
steps{
45
+ sh ''' docker pull quay.io/skopeo/stable:v1 || : '''
45
46
script{
46
47
env. EXIT_STATUS = ' '
47
48
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' || : ''' ,
49
50
returnStdout : true ). trim()
50
51
env. LS_RELEASE_NOTES = sh(
51
52
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 {
232
233
script{
233
234
env. SHELLCHECK_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /shellcheck-result.xml'
234
235
}
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'''
236
237
sh ''' #! /bin/bash
237
238
docker run --rm \
238
239
-v ${WORKSPACE}:/mnt \
@@ -380,6 +381,26 @@ pipeline {
380
381
}
381
382
}
382
383
}
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
+ }
383
404
/* #######################
384
405
GitLab Mirroring
385
406
####################### */
@@ -672,6 +693,7 @@ pipeline {
672
693
]) {
673
694
script{
674
695
env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
696
+ env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
675
697
}
676
698
sh ''' #! /bin/bash
677
699
set -e
@@ -698,8 +720,6 @@ pipeline {
698
720
-e WEB_SCREENSHOT=\" ${CI_WEB}\" \
699
721
-e WEB_AUTH=\" ${CI_AUTH}\" \
700
722
-e WEB_PATH=\" ${CI_WEBPATH}\" \
701
- -e DO_REGION="ams3" \
702
- -e DO_BUCKET="lsio-ci" \
703
723
-t ghcr.io/linuxserver/ci:latest \
704
724
python3 test_build.py'''
705
725
}
@@ -953,8 +973,67 @@ pipeline {
953
973
environment name : ' EXIT_STATUS' , value : ' '
954
974
}
955
975
steps {
956
- sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
957
- -d '{"body": "I am a bot, here are the test results for this PR: \\ n'${CI_URL}' \\ n'${SHELLCHECK_URL}'"}' '''
976
+ sh ''' #! /bin/bash
977
+ # Function to retrieve JSON data from URL
978
+ get_json() {
979
+ local url="$1"
980
+ local response=$(curl -s "$url")
981
+ if [ $? -ne 0 ]; then
982
+ echo "Failed to retrieve JSON data from $url"
983
+ return 1
984
+ fi
985
+ local json=$(echo "$response" | jq .)
986
+ if [ $? -ne 0 ]; then
987
+ echo "Failed to parse JSON data from $url"
988
+ return 1
989
+ fi
990
+ echo "$json"
991
+ }
992
+
993
+ build_table() {
994
+ local data="$1"
995
+
996
+ # Get the keys in the JSON data
997
+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
998
+
999
+ # Check if keys are empty
1000
+ if [ -z "$keys" ]; then
1001
+ echo "JSON report data does not contain any keys or the report does not exist."
1002
+ return 1
1003
+ fi
1004
+
1005
+ # Build table header
1006
+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1007
+
1008
+ # Loop through the JSON data to build the table rows
1009
+ local rows=""
1010
+ for build in $keys; do
1011
+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1012
+ if [ "$status" = "true" ]; then
1013
+ status="✅"
1014
+ else
1015
+ status="❌"
1016
+ fi
1017
+ local row="| "$build" | "$status" |\\ n"
1018
+ rows="${rows}${row}"
1019
+ done
1020
+
1021
+ local table="${header}${rows}"
1022
+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1023
+ echo "$escaped_table"
1024
+ }
1025
+
1026
+ # Retrieve JSON data from URL
1027
+ data=$(get_json "$CI_JSON_URL")
1028
+ # Create table from JSON data
1029
+ table=$(build_table "$data")
1030
+ echo -e "$table"
1031
+
1032
+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1033
+ -H "Accept: application/vnd.github.v3+json" \
1034
+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1035
+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"'''
1036
+
958
1037
}
959
1038
}
960
1039
}
0 commit comments