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