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