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