Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit e9bded6

Browse files
Bot Updating Templated Files
1 parent bf1ff3f commit e9bded6

1 file changed

Lines changed: 85 additions & 6 deletions

File tree

Jenkinsfile

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ pipeline {
4141
// Setup all the basic environment variables needed for the build
4242
stage("Set ENV Variables base"){
4343
steps{
44+
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
4445
script{
4546
env.EXIT_STATUS = ''
4647
env.LS_RELEASE = sh(
47-
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' || : ''',
48+
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' || : ''',
4849
returnStdout: true).trim()
4950
env.LS_RELEASE_NOTES = sh(
5051
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' ''',
@@ -230,7 +231,7 @@ pipeline {
230231
script{
231232
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
232233
}
233-
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
234+
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
234235
sh '''#! /bin/bash
235236
docker run --rm \
236237
-v ${WORKSPACE}:/mnt \
@@ -378,6 +379,26 @@ pipeline {
378379
}
379380
}
380381
}
382+
// If this is a master build check the S6 service file perms
383+
stage("Check S6 Service file Permissions"){
384+
when {
385+
branch "master"
386+
environment name: 'CHANGE_ID', value: ''
387+
environment name: 'EXIT_STATUS', value: ''
388+
}
389+
steps {
390+
script{
391+
sh '''#! /bin/bash
392+
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
393+
if [[ -n "${WRONG_PERM}" ]]; then
394+
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
395+
exit 1
396+
else
397+
echo "S6 service file perms look good."
398+
fi '''
399+
}
400+
}
401+
}
381402
/* #######################
382403
GitLab Mirroring
383404
####################### */
@@ -670,6 +691,7 @@ pipeline {
670691
]) {
671692
script{
672693
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
694+
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
673695
}
674696
sh '''#! /bin/bash
675697
set -e
@@ -696,8 +718,6 @@ pipeline {
696718
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
697719
-e WEB_AUTH=\"${CI_AUTH}\" \
698720
-e WEB_PATH=\"${CI_WEBPATH}\" \
699-
-e DO_REGION="ams3" \
700-
-e DO_BUCKET="lsio-ci" \
701721
-t ghcr.io/linuxserver/ci:latest \
702722
python3 test_build.py'''
703723
}
@@ -951,8 +971,67 @@ pipeline {
951971
environment name: 'EXIT_STATUS', value: ''
952972
}
953973
steps {
954-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
955-
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
974+
sh '''#! /bin/bash
975+
# Function to retrieve JSON data from URL
976+
get_json() {
977+
local url="$1"
978+
local response=$(curl -s "$url")
979+
if [ $? -ne 0 ]; then
980+
echo "Failed to retrieve JSON data from $url"
981+
return 1
982+
fi
983+
local json=$(echo "$response" | jq .)
984+
if [ $? -ne 0 ]; then
985+
echo "Failed to parse JSON data from $url"
986+
return 1
987+
fi
988+
echo "$json"
989+
}
990+
991+
build_table() {
992+
local data="$1"
993+
994+
# Get the keys in the JSON data
995+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
996+
997+
# Check if keys are empty
998+
if [ -z "$keys" ]; then
999+
echo "JSON report data does not contain any keys or the report does not exist."
1000+
return 1
1001+
fi
1002+
1003+
# Build table header
1004+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1005+
1006+
# Loop through the JSON data to build the table rows
1007+
local rows=""
1008+
for build in $keys; do
1009+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1010+
if [ "$status" = "true" ]; then
1011+
status="✅"
1012+
else
1013+
status="❌"
1014+
fi
1015+
local row="| "$build" | "$status" |\\n"
1016+
rows="${rows}${row}"
1017+
done
1018+
1019+
local table="${header}${rows}"
1020+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1021+
echo "$escaped_table"
1022+
}
1023+
1024+
# Retrieve JSON data from URL
1025+
data=$(get_json "$CI_JSON_URL")
1026+
# Create table from JSON data
1027+
table=$(build_table "$data")
1028+
echo -e "$table"
1029+
1030+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1031+
-H "Accept: application/vnd.github.v3+json" \
1032+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1033+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
1034+
9561035
}
9571036
}
9581037
}

0 commit comments

Comments
 (0)