@@ -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' ''' ,
@@ -238,7 +239,7 @@ pipeline {
238
239
script{
239
240
env. SHELLCHECK_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /shellcheck-result.xml'
240
241
}
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'''
242
243
sh ''' #! /bin/bash
243
244
docker run --rm \
244
245
-v ${WORKSPACE}:/mnt \
@@ -386,6 +387,26 @@ pipeline {
386
387
}
387
388
}
388
389
}
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
+ }
389
410
/* #######################
390
411
GitLab Mirroring
391
412
####################### */
@@ -678,6 +699,7 @@ pipeline {
678
699
]) {
679
700
script{
680
701
env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
702
+ env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
681
703
}
682
704
sh ''' #! /bin/bash
683
705
set -e
@@ -704,8 +726,6 @@ pipeline {
704
726
-e WEB_SCREENSHOT=\" ${CI_WEB}\" \
705
727
-e WEB_AUTH=\" ${CI_AUTH}\" \
706
728
-e WEB_PATH=\" ${CI_WEBPATH}\" \
707
- -e DO_REGION="ams3" \
708
- -e DO_BUCKET="lsio-ci" \
709
729
-t ghcr.io/linuxserver/ci:latest \
710
730
python3 test_build.py'''
711
731
}
@@ -959,8 +979,67 @@ pipeline {
959
979
environment name : ' EXIT_STATUS' , value : ' '
960
980
}
961
981
steps {
962
- sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
963
- -d '{"body": "I am a bot, here are the test results for this PR: \\ n'${CI_URL}' \\ n'${SHELLCHECK_URL}'"}' '''
982
+ sh ''' #! /bin/bash
983
+ # Function to retrieve JSON data from URL
984
+ get_json() {
985
+ local url="$1"
986
+ local response=$(curl -s "$url")
987
+ if [ $? -ne 0 ]; then
988
+ echo "Failed to retrieve JSON data from $url"
989
+ return 1
990
+ fi
991
+ local json=$(echo "$response" | jq .)
992
+ if [ $? -ne 0 ]; then
993
+ echo "Failed to parse JSON data from $url"
994
+ return 1
995
+ fi
996
+ echo "$json"
997
+ }
998
+
999
+ build_table() {
1000
+ local data="$1"
1001
+
1002
+ # Get the keys in the JSON data
1003
+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1004
+
1005
+ # Check if keys are empty
1006
+ if [ -z "$keys" ]; then
1007
+ echo "JSON report data does not contain any keys or the report does not exist."
1008
+ return 1
1009
+ fi
1010
+
1011
+ # Build table header
1012
+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1013
+
1014
+ # Loop through the JSON data to build the table rows
1015
+ local rows=""
1016
+ for build in $keys; do
1017
+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1018
+ if [ "$status" = "true" ]; then
1019
+ status="✅"
1020
+ else
1021
+ status="❌"
1022
+ fi
1023
+ local row="| "$build" | "$status" |\\ n"
1024
+ rows="${rows}${row}"
1025
+ done
1026
+
1027
+ local table="${header}${rows}"
1028
+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1029
+ echo "$escaped_table"
1030
+ }
1031
+
1032
+ # Retrieve JSON data from URL
1033
+ data=$(get_json "$CI_JSON_URL")
1034
+ # Create table from JSON data
1035
+ table=$(build_table "$data")
1036
+ echo -e "$table"
1037
+
1038
+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1039
+ -H "Accept: application/vnd.github.v3+json" \
1040
+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1041
+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"'''
1042
+
964
1043
}
965
1044
}
966
1045
}
0 commit comments