@@ -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}' :jammy 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} :jammy 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' ''' ,
@@ -56,7 +57,7 @@ pipeline {
5657 env. CODE_URL = ' https://github.com/' + env. LS_USER + ' /' + env. LS_REPO + ' /commit/' + env. GIT_COMMIT
5758 env. DOCKERHUB_LINK = ' https://hub.docker.com/r/' + env. DOCKERHUB_IMAGE + ' /tags/'
5859 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 '
6061 }
6162 script{
6263 env. LS_RELEASE_NUMBER = sh(
@@ -226,7 +227,7 @@ pipeline {
226227 script{
227228 env. SHELLCHECK_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /shellcheck-result.xml'
228229 }
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'''
230231 sh ''' #! /bin/bash
231232 docker run --rm \
232233 -v ${WORKSPACE}:/mnt \
@@ -273,6 +274,7 @@ pipeline {
273274 fi
274275 # Stage 2 - Delete old templates
275276 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)"
276278 for i in ${OLD_TEMPLATES}; do
277279 if [[ -f "${i}" ]]; then
278280 TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -307,6 +309,14 @@ pipeline {
307309 cd ${TEMPDIR}/docker-${CONTAINER_NAME}
308310 mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
309311 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
310320 cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
311321 cd ${TEMPDIR}/repo/${LS_REPO}/
312322 if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then
@@ -353,6 +363,26 @@ pipeline {
353363 }
354364 }
355365 }
366+ // If this is a jammy build check the S6 service file perms
367+ stage(" Check S6 Service file Permissions" ){
368+ when {
369+ branch " jammy"
370+ environment name : ' CHANGE_ID' , value : ' '
371+ environment name : ' EXIT_STATUS' , value : ' '
372+ }
373+ steps {
374+ script{
375+ sh ''' #! /bin/bash
376+ WRONG_PERM=$(find ./ -path "./.git" -prune -o \\ ( -name "run" -o -name "finish" -o -name "check" \\ ) -not -perm -u=x,g=x,o=x -print)
377+ if [[ -n "${WRONG_PERM}" ]]; then
378+ echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
379+ exit 1
380+ else
381+ echo "S6 service file perms look good."
382+ fi '''
383+ }
384+ }
385+ }
356386 /* #######################
357387 GitLab Mirroring
358388 ####################### */
@@ -627,6 +657,7 @@ pipeline {
627657 ]) {
628658 script{
629659 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
660+ env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
630661 }
631662 sh ''' #! /bin/bash
632663 set -e
@@ -653,8 +684,6 @@ pipeline {
653684 -e WEB_SCREENSHOT=\" ${CI_WEB}\" \
654685 -e WEB_AUTH=\" ${CI_AUTH}\" \
655686 -e WEB_PATH=\" ${CI_WEBPATH}\" \
656- -e DO_REGION="ams3" \
657- -e DO_BUCKET="lsio-ci" \
658687 -t ghcr.io/linuxserver/ci:latest \
659688 python3 test_build.py'''
660689 }
@@ -904,8 +933,86 @@ pipeline {
904933 environment name : ' EXIT_STATUS' , value : ' '
905934 }
906935 steps {
907- sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
908- -d '{"body": "I am a bot, here are the test results for this PR: \\ n'${CI_URL}' \\ n'${SHELLCHECK_URL}'"}' '''
936+ sh ''' #! /bin/bash
937+ # Function to retrieve JSON data from URL
938+ get_json() {
939+ local url="$1"
940+ local response=$(curl -s "$url")
941+ if [ $? -ne 0 ]; then
942+ echo "Failed to retrieve JSON data from $url"
943+ return 1
944+ fi
945+ local json=$(echo "$response" | jq .)
946+ if [ $? -ne 0 ]; then
947+ echo "Failed to parse JSON data from $url"
948+ return 1
949+ fi
950+ echo "$json"
951+ }
952+
953+ build_table() {
954+ local data="$1"
955+
956+ # Get the keys in the JSON data
957+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
958+
959+ # Check if keys are empty
960+ if [ -z "$keys" ]; then
961+ echo "JSON report data does not contain any keys or the report does not exist."
962+ return 1
963+ fi
964+
965+ # Build table header
966+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
967+
968+ # Loop through the JSON data to build the table rows
969+ local rows=""
970+ for build in $keys; do
971+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
972+ if [ "$status" = "true" ]; then
973+ status="✅"
974+ else
975+ status="❌"
976+ fi
977+ local row="| "$build" | "$status" |\\ n"
978+ rows="${rows}${row}"
979+ done
980+
981+ local table="${header}${rows}"
982+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
983+ echo "$escaped_table"
984+ }
985+
986+ # Retrieve JSON data from URL
987+ data=$(get_json "$CI_JSON_URL")
988+ # Create table from JSON data
989+ table=$(build_table "$data")
990+ echo -e "$table"
991+
992+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
993+ -H "Accept: application/vnd.github.v3+json" \
994+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
995+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"'''
996+
997+ }
998+ }
999+ stage(' Deprecate/Disable Future Builds' ) {
1000+ when {
1001+ branch " jammy"
1002+ environment name : ' CHANGE_ID' , value : ' '
1003+ environment name : ' EXIT_STATUS' , value : ' '
1004+ }
1005+ steps {
1006+ sh ''' #! /bin/bash
1007+ TEMPDIR=$(mktemp -d)
1008+ mkdir -p ${TEMPDIR}/repo
1009+ git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1010+ cd ${TEMPDIR}/repo/${LS_REPO}
1011+ git checkout -f jammy
1012+ git rm Jenkinsfile
1013+ git commit -m 'Disabling future builds'
1014+ git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
1015+ rm -Rf ${TEMPDIR}'''
9091016 }
9101017 }
9111018 }
0 commit comments