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