@@ -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}' :arch 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} :arch 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(
@@ -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 \
@@ -275,6 +276,7 @@ pipeline {
275276 fi
276277 # Stage 2 - Delete old templates
277278 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"
279+ 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)"
278280 for i in ${OLD_TEMPLATES}; do
279281 if [[ -f "${i}" ]]; then
280282 TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
@@ -309,6 +311,14 @@ pipeline {
309311 cd ${TEMPDIR}/docker-${CONTAINER_NAME}
310312 mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
311313 mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
314+ if [[ -d "${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d" ]]; then
315+ mkdir -p \
316+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-deprecate/dependencies.d \
317+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d \
318+ ${TEMPDIR}/repo/${LS_REPO}/root/etc/s6-overlay/s6-rc.d/user/contents.d
319+ else
320+ mkdir -p ${TEMPDIR}/repo/${LS_REPO}/root/etc/cont-init.d
321+ fi
312322 cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
313323 cd ${TEMPDIR}/repo/${LS_REPO}/
314324 if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then
@@ -355,6 +365,26 @@ pipeline {
355365 }
356366 }
357367 }
368+ // If this is a arch build check the S6 service file perms
369+ stage(" Check S6 Service file Permissions" ){
370+ when {
371+ branch " arch"
372+ environment name : ' CHANGE_ID' , value : ' '
373+ environment name : ' EXIT_STATUS' , value : ' '
374+ }
375+ steps {
376+ script{
377+ sh ''' #! /bin/bash
378+ WRONG_PERM=$(find ./ -path "./.git" -prune -o \\ ( -name "run" -o -name "finish" -o -name "check" \\ ) -not -perm -u=x,g=x,o=x -print)
379+ if [[ -n "${WRONG_PERM}" ]]; then
380+ echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
381+ exit 1
382+ else
383+ echo "S6 service file perms look good."
384+ fi '''
385+ }
386+ }
387+ }
358388 /* #######################
359389 GitLab Mirroring
360390 ####################### */
@@ -629,6 +659,7 @@ pipeline {
629659 ]) {
630660 script{
631661 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
662+ env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
632663 }
633664 sh ''' #! /bin/bash
634665 set -e
@@ -655,8 +686,6 @@ pipeline {
655686 -e WEB_SCREENSHOT=\" ${CI_WEB}\" \
656687 -e WEB_AUTH=\" ${CI_AUTH}\" \
657688 -e WEB_PATH=\" ${CI_WEBPATH}\" \
658- -e DO_REGION="ams3" \
659- -e DO_BUCKET="lsio-ci" \
660689 -t ghcr.io/linuxserver/ci:latest \
661690 python3 test_build.py'''
662691 }
@@ -906,8 +935,86 @@ pipeline {
906935 environment name : ' EXIT_STATUS' , value : ' '
907936 }
908937 steps {
909- sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
910- -d '{"body": "I am a bot, here are the test results for this PR: \\ n'${CI_URL}' \\ n'${SHELLCHECK_URL}'"}' '''
938+ sh ''' #! /bin/bash
939+ # Function to retrieve JSON data from URL
940+ get_json() {
941+ local url="$1"
942+ local response=$(curl -s "$url")
943+ if [ $? -ne 0 ]; then
944+ echo "Failed to retrieve JSON data from $url"
945+ return 1
946+ fi
947+ local json=$(echo "$response" | jq .)
948+ if [ $? -ne 0 ]; then
949+ echo "Failed to parse JSON data from $url"
950+ return 1
951+ fi
952+ echo "$json"
953+ }
954+
955+ build_table() {
956+ local data="$1"
957+
958+ # Get the keys in the JSON data
959+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
960+
961+ # Check if keys are empty
962+ if [ -z "$keys" ]; then
963+ echo "JSON report data does not contain any keys or the report does not exist."
964+ return 1
965+ fi
966+
967+ # Build table header
968+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
969+
970+ # Loop through the JSON data to build the table rows
971+ local rows=""
972+ for build in $keys; do
973+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
974+ if [ "$status" = "true" ]; then
975+ status="✅"
976+ else
977+ status="❌"
978+ fi
979+ local row="| "$build" | "$status" |\\ n"
980+ rows="${rows}${row}"
981+ done
982+
983+ local table="${header}${rows}"
984+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
985+ echo "$escaped_table"
986+ }
987+
988+ # Retrieve JSON data from URL
989+ data=$(get_json "$CI_JSON_URL")
990+ # Create table from JSON data
991+ table=$(build_table "$data")
992+ echo -e "$table"
993+
994+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
995+ -H "Accept: application/vnd.github.v3+json" \
996+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
997+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"'''
998+
999+ }
1000+ }
1001+ stage(' Deprecate/Disable Future Builds' ) {
1002+ when {
1003+ branch " arch"
1004+ environment name : ' CHANGE_ID' , value : ' '
1005+ environment name : ' EXIT_STATUS' , value : ' '
1006+ }
1007+ steps {
1008+ sh ''' #! /bin/bash
1009+ TEMPDIR=$(mktemp -d)
1010+ mkdir -p ${TEMPDIR}/repo
1011+ git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
1012+ cd ${TEMPDIR}/repo/${LS_REPO}
1013+ git checkout -f arch
1014+ git rm Jenkinsfile
1015+ git commit -m 'Disabling future builds'
1016+ git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
1017+ rm -Rf ${TEMPDIR}'''
9111018 }
9121019 }
9131020 }
0 commit comments