Skip to content

Commit 162364a

Browse files
Bot Updating Templated Files
1 parent dc61872 commit 162364a

1 file changed

Lines changed: 86 additions & 88 deletions

File tree

Jenkinsfile

Lines changed: 86 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pipeline {
7575
'''
7676
script{
7777
env.EXIT_STATUS = ''
78+
env.CI_TEST_ATTEMPTED = ''
7879
env.LS_RELEASE = sh(
7980
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:arch-xfce 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8081
returnStdout: true).trim()
@@ -283,7 +284,7 @@ pipeline {
283284
-v ${WORKSPACE}:/mnt \
284285
-e AWS_ACCESS_KEY_ID=\"${S3_KEY}\" \
285286
-e AWS_SECRET_ACCESS_KEY=\"${S3_SECRET}\" \
286-
ghcr.io/linuxserver/baseimage-alpine:3 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
287+
ghcr.io/linuxserver/baseimage-alpine:3.23 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
287288
apk add --no-cache python3 && \
288289
python3 -m venv /lsiopy && \
289290
pip install --no-cache-dir -U pip && \
@@ -808,6 +809,7 @@ pipeline {
808809
script{
809810
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
810811
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
812+
env.CI_TEST_ATTEMPTED = 'true'
811813
}
812814
sh '''#! /bin/bash
813815
set -e
@@ -1010,98 +1012,13 @@ EOF
10101012
) '''
10111013
}
10121014
}
1013-
// If this is a Pull request send the CI link as a comment on it
1014-
stage('Pull Request Comment') {
1015-
when {
1016-
not {environment name: 'CHANGE_ID', value: ''}
1017-
environment name: 'EXIT_STATUS', value: ''
1018-
}
1019-
steps {
1020-
sh '''#! /bin/bash
1021-
# Function to retrieve JSON data from URL
1022-
get_json() {
1023-
local url="$1"
1024-
local response=$(curl -s "$url")
1025-
if [ $? -ne 0 ]; then
1026-
echo "Failed to retrieve JSON data from $url"
1027-
return 1
1028-
fi
1029-
local json=$(echo "$response" | jq .)
1030-
if [ $? -ne 0 ]; then
1031-
echo "Failed to parse JSON data from $url"
1032-
return 1
1033-
fi
1034-
echo "$json"
1035-
}
1036-
1037-
build_table() {
1038-
local data="$1"
1039-
1040-
# Get the keys in the JSON data
1041-
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1042-
1043-
# Check if keys are empty
1044-
if [ -z "$keys" ]; then
1045-
echo "JSON report data does not contain any keys or the report does not exist."
1046-
return 1
1047-
fi
1048-
1049-
# Build table header
1050-
local header="| Tag | Passed |\\n| --- | --- |\\n"
1051-
1052-
# Loop through the JSON data to build the table rows
1053-
local rows=""
1054-
for build in $keys; do
1055-
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1056-
if [ "$status" = "true" ]; then
1057-
status="✅"
1058-
else
1059-
status="❌"
1060-
fi
1061-
local row="| "$build" | "$status" |\\n"
1062-
rows="${rows}${row}"
1063-
done
1064-
1065-
local table="${header}${rows}"
1066-
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1067-
echo "$escaped_table"
1068-
}
1069-
1070-
if [[ "${CI}" = "true" ]]; then
1071-
# Retrieve JSON data from URL
1072-
data=$(get_json "$CI_JSON_URL")
1073-
# Create table from JSON data
1074-
table=$(build_table "$data")
1075-
echo -e "$table"
1076-
1077-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1078-
-H "Accept: application/vnd.github.v3+json" \
1079-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1080-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1081-
else
1082-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1083-
-H "Accept: application/vnd.github.v3+json" \
1084-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1085-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1086-
fi
1087-
'''
1088-
1089-
}
1090-
}
10911015
}
10921016
/* ######################
1093-
Send status to Discord
1017+
Comment on PR and Send status to Discord
10941018
###################### */
10951019
post {
10961020
always {
1097-
sh '''#!/bin/bash
1098-
rm -rf /config/.ssh/id_sign
1099-
rm -rf /config/.ssh/id_sign.pub
1100-
git config --global --unset gpg.format
1101-
git config --global --unset user.signingkey
1102-
git config --global --unset commit.gpgsign
1103-
'''
1104-
script{
1021+
script {
11051022
env.JOB_DATE = sh(
11061023
script: '''date '+%Y-%m-%dT%H:%M:%S%:z' ''',
11071024
returnStdout: true).trim()
@@ -1144,6 +1061,87 @@ EOF
11441061
"username": "Jenkins"}' ${BUILDS_DISCORD} '''
11451062
}
11461063
}
1064+
script {
1065+
if (env.GITHUBIMAGE =~ /lspipepr/){
1066+
if (env.CI_TEST_ATTEMPTED == "true"){
1067+
sh '''#! /bin/bash
1068+
# Function to retrieve JSON data from URL
1069+
get_json() {
1070+
local url="$1"
1071+
local response=$(curl -s "$url")
1072+
if [ $? -ne 0 ]; then
1073+
echo "Failed to retrieve JSON data from $url"
1074+
return 1
1075+
fi
1076+
local json=$(echo "$response" | jq .)
1077+
if [ $? -ne 0 ]; then
1078+
echo "Failed to parse JSON data from $url"
1079+
return 1
1080+
fi
1081+
echo "$json"
1082+
}
1083+
1084+
build_table() {
1085+
local data="$1"
1086+
1087+
# Get the keys in the JSON data
1088+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1089+
1090+
# Check if keys are empty
1091+
if [ -z "$keys" ]; then
1092+
echo "JSON report data does not contain any keys or the report does not exist."
1093+
return 1
1094+
fi
1095+
1096+
# Build table header
1097+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1098+
1099+
# Loop through the JSON data to build the table rows
1100+
local rows=""
1101+
for build in $keys; do
1102+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1103+
if [ "$status" = "true" ]; then
1104+
status="✅"
1105+
else
1106+
status="❌"
1107+
fi
1108+
local row="| "$build" | "$status" |\\n"
1109+
rows="${rows}${row}"
1110+
done
1111+
1112+
local table="${header}${rows}"
1113+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1114+
echo "$escaped_table"
1115+
}
1116+
1117+
if [[ "${CI}" = "true" ]]; then
1118+
# Retrieve JSON data from URL
1119+
data=$(get_json "$CI_JSON_URL")
1120+
# Create table from JSON data
1121+
table=$(build_table "$data")
1122+
echo -e "$table"
1123+
1124+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1125+
-H "Accept: application/vnd.github.v3+json" \
1126+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1127+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1128+
else
1129+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1130+
-H "Accept: application/vnd.github.v3+json" \
1131+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1132+
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1133+
fi
1134+
'''
1135+
}
1136+
}
1137+
}
1138+
sh '''#!/bin/bash
1139+
rm -rf /config/.ssh/id_sign
1140+
rm -rf /config/.ssh/id_sign.pub
1141+
git config --global --unset gpg.format
1142+
git config --global --unset user.signingkey
1143+
git config --global --unset commit.gpgsign
1144+
'''
11471145
}
11481146
cleanup {
11491147
sh '''#! /bin/bash

0 commit comments

Comments
 (0)