Skip to content

Commit 5e1b742

Browse files
Bot Updating Templated Files
1 parent 8351174 commit 5e1b742

File tree

1 file changed

+85
-6
lines changed

1 file changed

+85
-6
lines changed

Jenkinsfile

+85-6
Original file line numberDiff line numberDiff line change
@@ -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}':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' || : ''',
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' ''',
@@ -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 \
@@ -374,6 +375,26 @@ pipeline {
374375
}
375376
}
376377
}
378+
// If this is a master build check the S6 service file perms
379+
stage("Check S6 Service file Permissions"){
380+
when {
381+
branch "master"
382+
environment name: 'CHANGE_ID', value: ''
383+
environment name: 'EXIT_STATUS', value: ''
384+
}
385+
steps {
386+
script{
387+
sh '''#! /bin/bash
388+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
389+
if [[ -n "${WRONG_PERM}" ]]; then
390+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
391+
exit 1
392+
else
393+
echo "S6 service file perms look good."
394+
fi '''
395+
}
396+
}
397+
}
377398
/* #######################
378399
GitLab Mirroring
379400
####################### */
@@ -666,6 +687,7 @@ pipeline {
666687
]) {
667688
script{
668689
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
690+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
669691
}
670692
sh '''#! /bin/bash
671693
set -e
@@ -692,8 +714,6 @@ pipeline {
692714
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
693715
-e WEB_AUTH=\"${CI_AUTH}\" \
694716
-e WEB_PATH=\"${CI_WEBPATH}\" \
695-
-e DO_REGION="ams3" \
696-
-e DO_BUCKET="lsio-ci" \
697717
-t ghcr.io/linuxserver/ci:latest \
698718
python3 test_build.py'''
699719
}
@@ -947,8 +967,67 @@ pipeline {
947967
environment name: 'EXIT_STATUS', value: ''
948968
}
949969
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}'"}' '''
970+
sh '''#! /bin/bash
971+
# Function to retrieve JSON data from URL
972+
get_json() {
973+
local url="$1"
974+
local response=$(curl -s "$url")
975+
if [ $? -ne 0 ]; then
976+
echo "Failed to retrieve JSON data from $url"
977+
return 1
978+
fi
979+
local json=$(echo "$response" | jq .)
980+
if [ $? -ne 0 ]; then
981+
echo "Failed to parse JSON data from $url"
982+
return 1
983+
fi
984+
echo "$json"
985+
}
986+
987+
build_table() {
988+
local data="$1"
989+
990+
# Get the keys in the JSON data
991+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
992+
993+
# Check if keys are empty
994+
if [ -z "$keys" ]; then
995+
echo "JSON report data does not contain any keys or the report does not exist."
996+
return 1
997+
fi
998+
999+
# Build table header
1000+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1001+
1002+
# Loop through the JSON data to build the table rows
1003+
local rows=""
1004+
for build in $keys; do
1005+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1006+
if [ "$status" = "true" ]; then
1007+
status="✅"
1008+
else
1009+
status="❌"
1010+
fi
1011+
local row="| "$build" | "$status" |\\n"
1012+
rows="${rows}${row}"
1013+
done
1014+
1015+
local table="${header}${rows}"
1016+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1017+
echo "$escaped_table"
1018+
}
1019+
1020+
# Retrieve JSON data from URL
1021+
data=$(get_json "$CI_JSON_URL")
1022+
# Create table from JSON data
1023+
table=$(build_table "$data")
1024+
echo -e "$table"
1025+
1026+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1027+
-H "Accept: application/vnd.github.v3+json" \
1028+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1029+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
1030+
9521031
}
9531032
}
9541033
}

0 commit comments

Comments
 (0)