Skip to content

Commit c225e4a

Browse files
Bot Updating Templated Files
1 parent d06485c commit c225e4a

File tree

1 file changed

+85
-87
lines changed

1 file changed

+85
-87
lines changed

Jenkinsfile

Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pipeline {
7676
'''
7777
script{
7878
env.EXIT_STATUS = ''
79+
env.CI_TEST_ATTEMPTED = ''
7980
env.LS_RELEASE = sh(
8081
script: '''docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:gpu-legacy 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
8182
returnStdout: true).trim()
@@ -879,6 +880,7 @@ pipeline {
879880
script{
880881
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
881882
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
883+
env.CI_TEST_ATTEMPTED = 'true'
882884
}
883885
sh '''#! /bin/bash
884886
set -e
@@ -1081,98 +1083,13 @@ EOF
10811083
) '''
10821084
}
10831085
}
1084-
// If this is a Pull request send the CI link as a comment on it
1085-
stage('Pull Request Comment') {
1086-
when {
1087-
not {environment name: 'CHANGE_ID', value: ''}
1088-
environment name: 'EXIT_STATUS', value: ''
1089-
}
1090-
steps {
1091-
sh '''#! /bin/bash
1092-
# Function to retrieve JSON data from URL
1093-
get_json() {
1094-
local url="$1"
1095-
local response=$(curl -s "$url")
1096-
if [ $? -ne 0 ]; then
1097-
echo "Failed to retrieve JSON data from $url"
1098-
return 1
1099-
fi
1100-
local json=$(echo "$response" | jq .)
1101-
if [ $? -ne 0 ]; then
1102-
echo "Failed to parse JSON data from $url"
1103-
return 1
1104-
fi
1105-
echo "$json"
1106-
}
1107-
1108-
build_table() {
1109-
local data="$1"
1110-
1111-
# Get the keys in the JSON data
1112-
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1113-
1114-
# Check if keys are empty
1115-
if [ -z "$keys" ]; then
1116-
echo "JSON report data does not contain any keys or the report does not exist."
1117-
return 1
1118-
fi
1119-
1120-
# Build table header
1121-
local header="| Tag | Passed |\\n| --- | --- |\\n"
1122-
1123-
# Loop through the JSON data to build the table rows
1124-
local rows=""
1125-
for build in $keys; do
1126-
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1127-
if [ "$status" = "true" ]; then
1128-
status="✅"
1129-
else
1130-
status="❌"
1131-
fi
1132-
local row="| "$build" | "$status" |\\n"
1133-
rows="${rows}${row}"
1134-
done
1135-
1136-
local table="${header}${rows}"
1137-
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1138-
echo "$escaped_table"
1139-
}
1140-
1141-
if [[ "${CI}" = "true" ]]; then
1142-
# Retrieve JSON data from URL
1143-
data=$(get_json "$CI_JSON_URL")
1144-
# Create table from JSON data
1145-
table=$(build_table "$data")
1146-
echo -e "$table"
1147-
1148-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1149-
-H "Accept: application/vnd.github.v3+json" \
1150-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1151-
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1152-
else
1153-
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1154-
-H "Accept: application/vnd.github.v3+json" \
1155-
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1156-
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1157-
fi
1158-
'''
1159-
1160-
}
1161-
}
11621086
}
11631087
/* ######################
1164-
Send status to Discord
1088+
Comment on PR and Send status to Discord
11651089
###################### */
11661090
post {
11671091
always {
1168-
sh '''#!/bin/bash
1169-
rm -rf /config/.ssh/id_sign
1170-
rm -rf /config/.ssh/id_sign.pub
1171-
git config --global --unset gpg.format
1172-
git config --global --unset user.signingkey
1173-
git config --global --unset commit.gpgsign
1174-
'''
1175-
script{
1092+
script {
11761093
env.JOB_DATE = sh(
11771094
script: '''date '+%Y-%m-%dT%H:%M:%S%:z' ''',
11781095
returnStdout: true).trim()
@@ -1215,6 +1132,87 @@ EOF
12151132
"username": "Jenkins"}' ${BUILDS_DISCORD} '''
12161133
}
12171134
}
1135+
script {
1136+
if (env.GITHUBIMAGE =~ /lspipepr/){
1137+
if (env.CI_TEST_ATTEMPTED == "true"){
1138+
sh '''#! /bin/bash
1139+
# Function to retrieve JSON data from URL
1140+
get_json() {
1141+
local url="$1"
1142+
local response=$(curl -s "$url")
1143+
if [ $? -ne 0 ]; then
1144+
echo "Failed to retrieve JSON data from $url"
1145+
return 1
1146+
fi
1147+
local json=$(echo "$response" | jq .)
1148+
if [ $? -ne 0 ]; then
1149+
echo "Failed to parse JSON data from $url"
1150+
return 1
1151+
fi
1152+
echo "$json"
1153+
}
1154+
1155+
build_table() {
1156+
local data="$1"
1157+
1158+
# Get the keys in the JSON data
1159+
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1160+
1161+
# Check if keys are empty
1162+
if [ -z "$keys" ]; then
1163+
echo "JSON report data does not contain any keys or the report does not exist."
1164+
return 1
1165+
fi
1166+
1167+
# Build table header
1168+
local header="| Tag | Passed |\\n| --- | --- |\\n"
1169+
1170+
# Loop through the JSON data to build the table rows
1171+
local rows=""
1172+
for build in $keys; do
1173+
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
1174+
if [ "$status" = "true" ]; then
1175+
status="✅"
1176+
else
1177+
status="❌"
1178+
fi
1179+
local row="| "$build" | "$status" |\\n"
1180+
rows="${rows}${row}"
1181+
done
1182+
1183+
local table="${header}${rows}"
1184+
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
1185+
echo "$escaped_table"
1186+
}
1187+
1188+
if [[ "${CI}" = "true" ]]; then
1189+
# Retrieve JSON data from URL
1190+
data=$(get_json "$CI_JSON_URL")
1191+
# Create table from JSON data
1192+
table=$(build_table "$data")
1193+
echo -e "$table"
1194+
1195+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1196+
-H "Accept: application/vnd.github.v3+json" \
1197+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1198+
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"
1199+
else
1200+
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1201+
-H "Accept: application/vnd.github.v3+json" \
1202+
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1203+
-d "{\\"body\\": \\"I am a bot, here is the pushed image/manifest for this PR: \\n\\n\\`${GITHUBIMAGE}:${META_TAG}\\`\\"}"
1204+
fi
1205+
'''
1206+
}
1207+
}
1208+
}
1209+
sh '''#!/bin/bash
1210+
rm -rf /config/.ssh/id_sign
1211+
rm -rf /config/.ssh/id_sign.pub
1212+
git config --global --unset gpg.format
1213+
git config --global --unset user.signingkey
1214+
git config --global --unset commit.gpgsign
1215+
'''
12181216
}
12191217
cleanup {
12201218
sh '''#! /bin/bash

0 commit comments

Comments
 (0)