@@ -39,10 +39,11 @@ pipeline {
39
39
// Setup all the basic environment variables needed for the build
40
40
stage(" Set ENV Variables base" ){
41
41
steps{
42
+ sh ''' docker pull quay.io/skopeo/stable:v1 || : '''
42
43
script{
43
44
env. EXIT_STATUS = ' '
44
45
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' || : ''' ,
46
47
returnStdout : true ). trim()
47
48
env. LS_RELEASE_NOTES = sh(
48
49
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' ''' ,
@@ -56,7 +57,7 @@ pipeline {
56
57
env. CODE_URL = ' https://github.com/' + env. LS_USER + ' /' + env. LS_REPO + ' /commit/' + env. GIT_COMMIT
57
58
env. DOCKERHUB_LINK = ' https://hub.docker.com/r/' + env. DOCKERHUB_IMAGE + ' /tags/'
58
59
env. PULL_REQUEST = env. CHANGE_ID
59
- env. TEMPLATED_FILES = ' Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/call_issue_pr_tracker.yml ./.github/workflows/call_issues_cron.yml ./.github/workflows/permissions.yml ./.github/workflows/external_trigger.yml ./.github/workflows/package_trigger.yml '
60
+ env. TEMPLATED_FILES = ' Jenkinsfile README.md LICENSE .editorconfig ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.yml ./.github/ISSUE_TEMPLATE/issue.feature.yml ./.github/PULL_REQUEST_TEMPLATE.md ./root/etc/cont-init.d/99-deprecation '
60
61
}
61
62
script{
62
63
env. LS_RELEASE_NUMBER = sh(
@@ -226,7 +227,7 @@ pipeline {
226
227
script{
227
228
env. SHELLCHECK_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /shellcheck-result.xml'
228
229
}
229
- sh ''' curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck /master/checkrun.sh | /bin/bash'''
230
+ sh ''' curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder /master/checkrun.sh | /bin/bash'''
230
231
sh ''' #! /bin/bash
231
232
docker run --rm \
232
233
-v ${WORKSPACE}:/mnt \
@@ -273,6 +274,7 @@ pipeline {
273
274
fi
274
275
# Stage 2 - Delete old templates
275
276
OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md .github/ISSUE_TEMPLATE/issue.bug.md .github/ISSUE_TEMPLATE/issue.feature.md .github/workflows/call_invalid_helper.yml .github/workflows/stale.yml"
277
+ OLD_TEMPLATES="${OLD_TEMPLATES} $(echo .github/workflows/{external_trigger,external_trigger_scheduler,package_trigger,package_trigger_scheduler,call_issue_pr_tracker,call_issues_cron}.yml)"
276
278
for i in ${OLD_TEMPLATES}; do
277
279
if [[ -f "${i}" ]]; then
278
280
TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -307,6 +309,14 @@ pipeline {
307
309
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
308
310
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
309
311
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
312
+ if [[ -d "${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d" ]]; then
313
+ mkdir -p \
314
+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
315
+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
316
+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
317
+ else
318
+ mkdir -p ${TEMPDIR}/repo/${LS_REPO}/root/etc/cont-init.d
319
+ fi
310
320
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
311
321
cd ${TEMPDIR}/repo/${LS_REPO}/
312
322
if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then
@@ -337,6 +347,10 @@ pipeline {
337
347
fi
338
348
if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then
339
349
cd ${TEMPDIR}/unraid/templates/
350
+ if ! grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
351
+ echo "${CONTAINER_NAME}" >> ${TEMPDIR}/unraid/templates/unraid/ignore.list
352
+ git add unraid/ignore.list
353
+ fi
340
354
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
341
355
echo "Image is on the ignore list, marking Unraid template as deprecated"
342
356
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
@@ -374,6 +388,26 @@ pipeline {
374
388
}
375
389
}
376
390
}
391
+ // If this is a master build check the S6 service file perms
392
+ stage(" Check S6 Service file Permissions" ){
393
+ when {
394
+ branch " master"
395
+ environment name : ' CHANGE_ID' , value : ' '
396
+ environment name : ' EXIT_STATUS' , value : ' '
397
+ }
398
+ steps {
399
+ script{
400
+ sh ''' #! /bin/bash
401
+ WRONG_PERM=$(find ./ -path "./.git" -prune -o \\ ( -name "run" -o -name "finish" -o -name "check" \\ ) -not -perm -u=x,g=x,o=x -print)
402
+ if [[ -n "${WRONG_PERM}" ]]; then
403
+ echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
404
+ exit 1
405
+ else
406
+ echo "S6 service file perms look good."
407
+ fi '''
408
+ }
409
+ }
410
+ }
377
411
/* #######################
378
412
GitLab Mirroring
379
413
####################### */
@@ -666,6 +700,7 @@ pipeline {
666
700
]) {
667
701
script{
668
702
env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
703
+ env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
669
704
}
670
705
sh ''' #! /bin/bash
671
706
set -e
@@ -692,8 +727,6 @@ pipeline {
692
727
-e WEB_SCREENSHOT=\" ${CI_WEB}\" \
693
728
-e WEB_AUTH=\" ${CI_AUTH}\" \
694
729
-e WEB_PATH=\" ${CI_WEBPATH}\" \
695
- -e DO_REGION="ams3" \
696
- -e DO_BUCKET="lsio-ci" \
697
730
-t ghcr.io/linuxserver/ci:latest \
698
731
python3 test_build.py'''
699
732
}
@@ -947,8 +980,86 @@ pipeline {
947
980
environment name : ' EXIT_STATUS' , value : ' '
948
981
}
949
982
steps {
950
- sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
951
- -d '{"body": "I am a bot, here are the test results for this PR: \\ n'${CI_URL}' \\ n'${SHELLCHECK_URL}'"}' '''
983
+ sh ''' #! /bin/bash
984
+ # Function to retrieve JSON data from URL
985
+ get_json() {
986
+ local url="$1"
987
+ local response=$(curl -s "$url")
988
+ if [ $? -ne 0 ]; then
989
+ echo "Failed to retrieve JSON data from $url"
990
+ return 1
991
+ fi
992
+ local json=$(echo "$response" | jq .)
993
+ if [ $? -ne 0 ]; then
994
+ echo "Failed to parse JSON data from $url"
995
+ return 1
996
+ fi
997
+ echo "$json"
998
+ }
999
+
1000
+ build_table() {
1001
+ local data="$1"
1002
+
1003
+ # Get the keys in the JSON data
1004
+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1005
+
1006
+ # Check if keys are empty
1007
+ if [ -z "$keys" ]; then
1008
+ echo "JSON report data does not contain any keys or the report does not exist."
1009
+ return 1
1010
+ fi
1011
+
1012
+ # Build table header
1013
+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1014
+
1015
+ # Loop through the JSON data to build the table rows
1016
+ local rows=""
1017
+ for build in $keys; do
1018
+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1019
+ if [ "$status" = "true" ]; then
1020
+ status="✅"
1021
+ else
1022
+ status="❌"
1023
+ fi
1024
+ local row="| "$build" | "$status" |\\ n"
1025
+ rows="${rows}${row}"
1026
+ done
1027
+
1028
+ local table="${header}${rows}"
1029
+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1030
+ echo "$escaped_table"
1031
+ }
1032
+
1033
+ # Retrieve JSON data from URL
1034
+ data=$(get_json "$CI_JSON_URL")
1035
+ # Create table from JSON data
1036
+ table=$(build_table "$data")
1037
+ echo -e "$table"
1038
+
1039
+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1040
+ -H "Accept: application/vnd.github.v3+json" \
1041
+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1042
+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"'''
1043
+
1044
+ }
1045
+ }
1046
+ stage(' Deprecate/Disable Future Builds' ) {
1047
+ when {
1048
+ branch " master"
1049
+ environment name : ' CHANGE_ID' , value : ' '
1050
+ environment name : ' EXIT_STATUS' , value : ' '
1051
+ }
1052
+ steps {
1053
+ sh ''' #! /bin/bash
1054
+ TEMPDIR=$(mktemp -d)
1055
+ mkdir -p ${TEMPDIR}/repo
1056
+ git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1057
+ cd ${TEMPDIR}/repo/${LS_REPO}
1058
+ git checkout -f master
1059
+ git rm Jenkinsfile
1060
+ git commit -m 'Disabling future builds'
1061
+ git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
1062
+ rm -Rf ${TEMPDIR}'''
952
1063
}
953
1064
}
954
1065
}
0 commit comments