@@ -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()
@@ -846,6 +847,7 @@ pipeline {
846847 script{
847848 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
848849 env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
850+ env. CI_TEST_ATTEMPTED = ' true'
849851 }
850852 sh ''' #! /bin/bash
851853 set -e
@@ -1048,98 +1050,13 @@ EOF
10481050 ) '''
10491051 }
10501052 }
1051- // If this is a Pull request send the CI link as a comment on it
1052- stage(' Pull Request Comment' ) {
1053- when {
1054- not {environment name : ' CHANGE_ID' , value : ' ' }
1055- environment name : ' EXIT_STATUS' , value : ' '
1056- }
1057- steps {
1058- sh ''' #! /bin/bash
1059- # Function to retrieve JSON data from URL
1060- get_json() {
1061- local url="$1"
1062- local response=$(curl -s "$url")
1063- if [ $? -ne 0 ]; then
1064- echo "Failed to retrieve JSON data from $url"
1065- return 1
1066- fi
1067- local json=$(echo "$response" | jq .)
1068- if [ $? -ne 0 ]; then
1069- echo "Failed to parse JSON data from $url"
1070- return 1
1071- fi
1072- echo "$json"
1073- }
1074-
1075- build_table() {
1076- local data="$1"
1077-
1078- # Get the keys in the JSON data
1079- local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1080-
1081- # Check if keys are empty
1082- if [ -z "$keys" ]; then
1083- echo "JSON report data does not contain any keys or the report does not exist."
1084- return 1
1085- fi
1086-
1087- # Build table header
1088- local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1089-
1090- # Loop through the JSON data to build the table rows
1091- local rows=""
1092- for build in $keys; do
1093- local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1094- if [ "$status" = "true" ]; then
1095- status="✅"
1096- else
1097- status="❌"
1098- fi
1099- local row="| "$build" | "$status" |\\ n"
1100- rows="${rows}${row}"
1101- done
1102-
1103- local table="${header}${rows}"
1104- local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1105- echo "$escaped_table"
1106- }
1107-
1108- if [[ "${CI}" = "true" ]]; then
1109- # Retrieve JSON data from URL
1110- data=$(get_json "$CI_JSON_URL")
1111- # Create table from JSON data
1112- table=$(build_table "$data")
1113- echo -e "$table"
1114-
1115- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1116- -H "Accept: application/vnd.github.v3+json" \
1117- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1118- -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1119- else
1120- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1121- -H "Accept: application/vnd.github.v3+json" \
1122- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1123- -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1124- fi
1125- '''
1126-
1127- }
1128- }
11291053 }
11301054 /* ######################
1131- Send status to Discord
1055+ Comment on PR and Send status to Discord
11321056 ###################### */
11331057 post {
11341058 always {
1135- sh ''' #!/bin/bash
1136- rm -rf /config/.ssh/id_sign
1137- rm -rf /config/.ssh/id_sign.pub
1138- git config --global --unset gpg.format
1139- git config --global --unset user.signingkey
1140- git config --global --unset commit.gpgsign
1141- '''
1142- script{
1059+ script {
11431060 env. JOB_DATE = sh(
11441061 script : ''' date '+%Y-%m-%dT%H:%M:%S%:z' ''' ,
11451062 returnStdout : true ). trim()
@@ -1182,6 +1099,87 @@ EOF
11821099 "username": "Jenkins"}' ${BUILDS_DISCORD} '''
11831100 }
11841101 }
1102+ script {
1103+ if (env. GITHUBIMAGE =~ / lspipepr/ ){
1104+ if (env. CI_TEST_ATTEMPTED == " true" ){
1105+ sh ''' #! /bin/bash
1106+ # Function to retrieve JSON data from URL
1107+ get_json() {
1108+ local url="$1"
1109+ local response=$(curl -s "$url")
1110+ if [ $? -ne 0 ]; then
1111+ echo "Failed to retrieve JSON data from $url"
1112+ return 1
1113+ fi
1114+ local json=$(echo "$response" | jq .)
1115+ if [ $? -ne 0 ]; then
1116+ echo "Failed to parse JSON data from $url"
1117+ return 1
1118+ fi
1119+ echo "$json"
1120+ }
1121+
1122+ build_table() {
1123+ local data="$1"
1124+
1125+ # Get the keys in the JSON data
1126+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1127+
1128+ # Check if keys are empty
1129+ if [ -z "$keys" ]; then
1130+ echo "JSON report data does not contain any keys or the report does not exist."
1131+ return 1
1132+ fi
1133+
1134+ # Build table header
1135+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1136+
1137+ # Loop through the JSON data to build the table rows
1138+ local rows=""
1139+ for build in $keys; do
1140+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1141+ if [ "$status" = "true" ]; then
1142+ status="✅"
1143+ else
1144+ status="❌"
1145+ fi
1146+ local row="| "$build" | "$status" |\\ n"
1147+ rows="${rows}${row}"
1148+ done
1149+
1150+ local table="${header}${rows}"
1151+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1152+ echo "$escaped_table"
1153+ }
1154+
1155+ if [[ "${CI}" = "true" ]]; then
1156+ # Retrieve JSON data from URL
1157+ data=$(get_json "$CI_JSON_URL")
1158+ # Create table from JSON data
1159+ table=$(build_table "$data")
1160+ echo -e "$table"
1161+
1162+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1163+ -H "Accept: application/vnd.github.v3+json" \
1164+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1165+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1166+ else
1167+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1168+ -H "Accept: application/vnd.github.v3+json" \
1169+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1170+ -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1171+ fi
1172+ '''
1173+ }
1174+ }
1175+ }
1176+ sh ''' #!/bin/bash
1177+ rm -rf /config/.ssh/id_sign
1178+ rm -rf /config/.ssh/id_sign.pub
1179+ git config --global --unset gpg.format
1180+ git config --global --unset user.signingkey
1181+ git config --global --unset commit.gpgsign
1182+ '''
11851183 }
11861184 cleanup {
11871185 sh ''' #! /bin/bash
0 commit comments