Skip to content

Commit 6c4e9bd

Browse files
Bot Updating Templated Files
1 parent 3eb91af commit 6c4e9bd

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
@@ -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' ''',
@@ -232,7 +233,7 @@ pipeline {
232233
script{
233234
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
234235
}
235-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
236+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
236237
sh '''#! /bin/bash
237238
docker run --rm \
238239
-v ${WORKSPACE}:/mnt \
@@ -380,6 +381,26 @@ pipeline {
380381
}
381382
}
382383
}
384+
// If this is a master build check the S6 service file perms
385+
stage("Check S6 Service file Permissions"){
386+
when {
387+
branch "master"
388+
environment name: 'CHANGE_ID', value: ''
389+
environment name: 'EXIT_STATUS', value: ''
390+
}
391+
steps {
392+
script{
393+
sh '''#! /bin/bash
394+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
395+
if [[ -n "${WRONG_PERM}" ]]; then
396+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
397+
exit 1
398+
else
399+
echo "S6 service file perms look good."
400+
fi '''
401+
}
402+
}
403+
}
383404
/* #######################
384405
GitLab Mirroring
385406
####################### */
@@ -672,6 +693,7 @@ pipeline {
672693
]) {
673694
script{
674695
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
696+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
675697
}
676698
sh '''#! /bin/bash
677699
set -e
@@ -698,8 +720,6 @@ pipeline {
698720
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
699721
-e WEB_AUTH=\"${CI_AUTH}\" \
700722
-e WEB_PATH=\"${CI_WEBPATH}\" \
701-
-e DO_REGION="ams3" \
702-
-e DO_BUCKET="lsio-ci" \
703723
-t ghcr.io/linuxserver/ci:latest \
704724
python3 test_build.py'''
705725
}
@@ -953,8 +973,67 @@ pipeline {
953973
environment name: 'EXIT_STATUS', value: ''
954974
}
955975
steps {
956-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
957-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
976+
sh '''#! /bin/bash
977+
# Function to retrieve JSON data from URL
978+
get_json() {
979+
local url="$1"
980+
local response=$(curl -s "$url")
981+
if [ $? -ne 0 ]; then
982+
echo "Failed to retrieve JSON data from $url"
983+
return 1
984+
fi
985+
local json=$(echo "$response" | jq .)
986+
if [ $? -ne 0 ]; then
987+
echo "Failed to parse JSON data from $url"
988+
return 1
989+
fi
990+
echo "$json"
991+
}
992+
993+
build_table() {
994+
local data="$1"
995+
996+
# Get the keys in the JSON data
997+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
998+
999+
# Check if keys are empty
1000+
if [ -z "$keys" ]; then
1001+
echo "JSON report data does not contain any keys or the report does not exist."
1002+
return 1
1003+
fi
1004+
1005+
# Build table header
1006+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1007+
1008+
# Loop through the JSON data to build the table rows
1009+
local rows=""
1010+
for build in $keys; do
1011+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1012+
if [ "$status" = "true" ]; then
1013+
status="✅"
1014+
else
1015+
status="❌"
1016+
fi
1017+
local row="| "$build" | "$status" |\\n"
1018+
rows="${rows}${row}"
1019+
done
1020+
1021+
local table="${header}${rows}"
1022+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1023+
echo "$escaped_table"
1024+
}
1025+
1026+
# Retrieve JSON data from URL
1027+
data=$(get_json "$CI_JSON_URL")
1028+
# Create table from JSON data
1029+
table=$(build_table "$data")
1030+
echo -e "$table"
1031+
1032+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1033+
-H "Accept: application/vnd.github.v3+json" \
1034+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1035+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
1036+
9581037
}
9591038
}
9601039
}

0 commit comments

Comments
 (0)