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