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