@@ -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}:latest 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\ -ls' || : ''' ,
8081 returnStdout : true ). trim()
@@ -869,6 +870,7 @@ pipeline {
869870 script{
870871 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
871872 env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
873+ env. CI_TEST_ATTEMPTED = ' true'
872874 }
873875 sh ''' #! /bin/bash
874876 set -e
@@ -1071,98 +1073,13 @@ EOF
10711073 ) '''
10721074 }
10731075 }
1074- // If this is a Pull request send the CI link as a comment on it
1075- stage(' Pull Request Comment' ) {
1076- when {
1077- not {environment name : ' CHANGE_ID' , value : ' ' }
1078- environment name : ' EXIT_STATUS' , value : ' '
1079- }
1080- steps {
1081- sh ''' #! /bin/bash
1082- # Function to retrieve JSON data from URL
1083- get_json() {
1084- local url="$1"
1085- local response=$(curl -s "$url")
1086- if [ $? -ne 0 ]; then
1087- echo "Failed to retrieve JSON data from $url"
1088- return 1
1089- fi
1090- local json=$(echo "$response" | jq .)
1091- if [ $? -ne 0 ]; then
1092- echo "Failed to parse JSON data from $url"
1093- return 1
1094- fi
1095- echo "$json"
1096- }
1097-
1098- build_table() {
1099- local data="$1"
1100-
1101- # Get the keys in the JSON data
1102- local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1103-
1104- # Check if keys are empty
1105- if [ -z "$keys" ]; then
1106- echo "JSON report data does not contain any keys or the report does not exist."
1107- return 1
1108- fi
1109-
1110- # Build table header
1111- local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1112-
1113- # Loop through the JSON data to build the table rows
1114- local rows=""
1115- for build in $keys; do
1116- local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1117- if [ "$status" = "true" ]; then
1118- status="✅"
1119- else
1120- status="❌"
1121- fi
1122- local row="| "$build" | "$status" |\\ n"
1123- rows="${rows}${row}"
1124- done
1125-
1126- local table="${header}${rows}"
1127- local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1128- echo "$escaped_table"
1129- }
1130-
1131- if [[ "${CI}" = "true" ]]; then
1132- # Retrieve JSON data from URL
1133- data=$(get_json "$CI_JSON_URL")
1134- # Create table from JSON data
1135- table=$(build_table "$data")
1136- echo -e "$table"
1137-
1138- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1139- -H "Accept: application/vnd.github.v3+json" \
1140- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1141- -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1142- else
1143- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1144- -H "Accept: application/vnd.github.v3+json" \
1145- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1146- -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1147- fi
1148- '''
1149-
1150- }
1151- }
11521076 }
11531077 /* ######################
1154- Send status to Discord
1078+ Comment on PR and Send status to Discord
11551079 ###################### */
11561080 post {
11571081 always {
1158- sh ''' #!/bin/bash
1159- rm -rf /config/.ssh/id_sign
1160- rm -rf /config/.ssh/id_sign.pub
1161- git config --global --unset gpg.format
1162- git config --global --unset user.signingkey
1163- git config --global --unset commit.gpgsign
1164- '''
1165- script{
1082+ script {
11661083 env. JOB_DATE = sh(
11671084 script : ''' date '+%Y-%m-%dT%H:%M:%S%:z' ''' ,
11681085 returnStdout : true ). trim()
@@ -1205,6 +1122,87 @@ EOF
12051122 "username": "Jenkins"}' ${BUILDS_DISCORD} '''
12061123 }
12071124 }
1125+ script {
1126+ if (env. GITHUBIMAGE =~ / lspipepr/ ){
1127+ if (env. CI_TEST_ATTEMPTED == " true" ){
1128+ sh ''' #! /bin/bash
1129+ # Function to retrieve JSON data from URL
1130+ get_json() {
1131+ local url="$1"
1132+ local response=$(curl -s "$url")
1133+ if [ $? -ne 0 ]; then
1134+ echo "Failed to retrieve JSON data from $url"
1135+ return 1
1136+ fi
1137+ local json=$(echo "$response" | jq .)
1138+ if [ $? -ne 0 ]; then
1139+ echo "Failed to parse JSON data from $url"
1140+ return 1
1141+ fi
1142+ echo "$json"
1143+ }
1144+
1145+ build_table() {
1146+ local data="$1"
1147+
1148+ # Get the keys in the JSON data
1149+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1150+
1151+ # Check if keys are empty
1152+ if [ -z "$keys" ]; then
1153+ echo "JSON report data does not contain any keys or the report does not exist."
1154+ return 1
1155+ fi
1156+
1157+ # Build table header
1158+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1159+
1160+ # Loop through the JSON data to build the table rows
1161+ local rows=""
1162+ for build in $keys; do
1163+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1164+ if [ "$status" = "true" ]; then
1165+ status="✅"
1166+ else
1167+ status="❌"
1168+ fi
1169+ local row="| "$build" | "$status" |\\ n"
1170+ rows="${rows}${row}"
1171+ done
1172+
1173+ local table="${header}${rows}"
1174+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1175+ echo "$escaped_table"
1176+ }
1177+
1178+ if [[ "${CI}" = "true" ]]; then
1179+ # Retrieve JSON data from URL
1180+ data=$(get_json "$CI_JSON_URL")
1181+ # Create table from JSON data
1182+ table=$(build_table "$data")
1183+ echo -e "$table"
1184+
1185+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1186+ -H "Accept: application/vnd.github.v3+json" \
1187+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1188+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1189+ else
1190+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1191+ -H "Accept: application/vnd.github.v3+json" \
1192+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1193+ -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1194+ fi
1195+ '''
1196+ }
1197+ }
1198+ }
1199+ sh ''' #!/bin/bash
1200+ rm -rf /config/.ssh/id_sign
1201+ rm -rf /config/.ssh/id_sign.pub
1202+ git config --global --unset gpg.format
1203+ git config --global --unset user.signingkey
1204+ git config --global --unset commit.gpgsign
1205+ '''
12081206 }
12091207 cleanup {
12101208 sh ''' #! /bin/bash
0 commit comments