Skip to content

Commit 1fad6af

Browse files
Bot Updating Templated Files
1 parent 1939f83 commit 1fad6af

File tree

1 file changed

+85
-6
lines changed

1 file changed

+85
-6
lines changed

Jenkinsfile

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ pipeline {
4242
// Setup all the basic environment variables needed for the build
4343
stage("Set ENV Variables base"){
4444
steps{
45+
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
4546
script{
4647
env.EXIT_STATUS = ''
4748
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' || : ''',
4950
returnStdout: true).trim()
5051
env.LS_RELEASE_NOTES = sh(
5152
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 {
238239
script{
239240
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
240241
}
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'''
242243
sh '''#! /bin/bash
243244
docker run --rm \
244245
-v ${WORKSPACE}:/mnt \
@@ -386,6 +387,26 @@ pipeline {
386387
}
387388
}
388389
}
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+
}
389410
/* #######################
390411
GitLab Mirroring
391412
####################### */
@@ -678,6 +699,7 @@ pipeline {
678699
]) {
679700
script{
680701
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'
681703
}
682704
sh '''#! /bin/bash
683705
set -e
@@ -704,8 +726,6 @@ pipeline {
704726
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
705727
-e WEB_AUTH=\"${CI_AUTH}\" \
706728
-e WEB_PATH=\"${CI_WEBPATH}\" \
707-
-e DO_REGION="ams3" \
708-
-e DO_BUCKET="lsio-ci" \
709729
-t ghcr.io/linuxserver/ci:latest \
710730
python3 test_build.py'''
711731
}
@@ -959,8 +979,67 @@ pipeline {
959979
environment name: 'EXIT_STATUS', value: ''
960980
}
961981
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+
9641043
}
9651044
}
9661045
}

0 commit comments

Comments
 (0)