@@ -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()
@@ -818,6 +819,7 @@ pipeline {
818819 script{
819820 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
820821 env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
822+ env. CI_TEST_ATTEMPTED = ' true'
821823 }
822824 sh ''' #! /bin/bash
823825 set -e
@@ -1020,98 +1022,13 @@ EOF
10201022 ) '''
10211023 }
10221024 }
1023- // If this is a Pull request send the CI link as a comment on it
1024- stage(' Pull Request Comment' ) {
1025- when {
1026- not {environment name : ' CHANGE_ID' , value : ' ' }
1027- environment name : ' EXIT_STATUS' , value : ' '
1028- }
1029- steps {
1030- sh ''' #! /bin/bash
1031- # Function to retrieve JSON data from URL
1032- get_json() {
1033- local url="$1"
1034- local response=$(curl -s "$url")
1035- if [ $? -ne 0 ]; then
1036- echo "Failed to retrieve JSON data from $url"
1037- return 1
1038- fi
1039- local json=$(echo "$response" | jq .)
1040- if [ $? -ne 0 ]; then
1041- echo "Failed to parse JSON data from $url"
1042- return 1
1043- fi
1044- echo "$json"
1045- }
1046-
1047- build_table() {
1048- local data="$1"
1049-
1050- # Get the keys in the JSON data
1051- local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1052-
1053- # Check if keys are empty
1054- if [ -z "$keys" ]; then
1055- echo "JSON report data does not contain any keys or the report does not exist."
1056- return 1
1057- fi
1058-
1059- # Build table header
1060- local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1061-
1062- # Loop through the JSON data to build the table rows
1063- local rows=""
1064- for build in $keys; do
1065- local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1066- if [ "$status" = "true" ]; then
1067- status="✅"
1068- else
1069- status="❌"
1070- fi
1071- local row="| "$build" | "$status" |\\ n"
1072- rows="${rows}${row}"
1073- done
1074-
1075- local table="${header}${rows}"
1076- local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1077- echo "$escaped_table"
1078- }
1079-
1080- if [[ "${CI}" = "true" ]]; then
1081- # Retrieve JSON data from URL
1082- data=$(get_json "$CI_JSON_URL")
1083- # Create table from JSON data
1084- table=$(build_table "$data")
1085- echo -e "$table"
1086-
1087- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1088- -H "Accept: application/vnd.github.v3+json" \
1089- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1090- -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1091- else
1092- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1093- -H "Accept: application/vnd.github.v3+json" \
1094- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1095- -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1096- fi
1097- '''
1098-
1099- }
1100- }
11011025 }
11021026 /* ######################
1103- Send status to Discord
1027+ Comment on PR and Send status to Discord
11041028 ###################### */
11051029 post {
11061030 always {
1107- sh ''' #!/bin/bash
1108- rm -rf /config/.ssh/id_sign
1109- rm -rf /config/.ssh/id_sign.pub
1110- git config --global --unset gpg.format
1111- git config --global --unset user.signingkey
1112- git config --global --unset commit.gpgsign
1113- '''
1114- script{
1031+ script {
11151032 env. JOB_DATE = sh(
11161033 script : ''' date '+%Y-%m-%dT%H:%M:%S%:z' ''' ,
11171034 returnStdout : true ). trim()
@@ -1154,6 +1071,87 @@ EOF
11541071 "username": "Jenkins"}' ${BUILDS_DISCORD} '''
11551072 }
11561073 }
1074+ script {
1075+ if (env. GITHUBIMAGE =~ / lspipepr/ ){
1076+ if (env. CI_TEST_ATTEMPTED == " true" ){
1077+ sh ''' #! /bin/bash
1078+ # Function to retrieve JSON data from URL
1079+ get_json() {
1080+ local url="$1"
1081+ local response=$(curl -s "$url")
1082+ if [ $? -ne 0 ]; then
1083+ echo "Failed to retrieve JSON data from $url"
1084+ return 1
1085+ fi
1086+ local json=$(echo "$response" | jq .)
1087+ if [ $? -ne 0 ]; then
1088+ echo "Failed to parse JSON data from $url"
1089+ return 1
1090+ fi
1091+ echo "$json"
1092+ }
1093+
1094+ build_table() {
1095+ local data="$1"
1096+
1097+ # Get the keys in the JSON data
1098+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1099+
1100+ # Check if keys are empty
1101+ if [ -z "$keys" ]; then
1102+ echo "JSON report data does not contain any keys or the report does not exist."
1103+ return 1
1104+ fi
1105+
1106+ # Build table header
1107+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1108+
1109+ # Loop through the JSON data to build the table rows
1110+ local rows=""
1111+ for build in $keys; do
1112+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1113+ if [ "$status" = "true" ]; then
1114+ status="✅"
1115+ else
1116+ status="❌"
1117+ fi
1118+ local row="| "$build" | "$status" |\\ n"
1119+ rows="${rows}${row}"
1120+ done
1121+
1122+ local table="${header}${rows}"
1123+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1124+ echo "$escaped_table"
1125+ }
1126+
1127+ if [[ "${CI}" = "true" ]]; then
1128+ # Retrieve JSON data from URL
1129+ data=$(get_json "$CI_JSON_URL")
1130+ # Create table from JSON data
1131+ table=$(build_table "$data")
1132+ echo -e "$table"
1133+
1134+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1135+ -H "Accept: application/vnd.github.v3+json" \
1136+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1137+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1138+ else
1139+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1140+ -H "Accept: application/vnd.github.v3+json" \
1141+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1142+ -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1143+ fi
1144+ '''
1145+ }
1146+ }
1147+ }
1148+ sh ''' #!/bin/bash
1149+ rm -rf /config/.ssh/id_sign
1150+ rm -rf /config/.ssh/id_sign.pub
1151+ git config --global --unset gpg.format
1152+ git config --global --unset user.signingkey
1153+ git config --global --unset commit.gpgsign
1154+ '''
11571155 }
11581156 cleanup {
11591157 sh ''' #! /bin/bash
0 commit comments