@@ -75,6 +75,7 @@ pipeline {
7575 '''
7676 script{
7777 env. EXIT_STATUS = ' '
78+ env. CI_TEST_ATTEMPTED = ' '
7879 env. LS_RELEASE = sh(
7980 script : ''' docker run --rm quay.io/skopeo/stable:v1 inspect docker://ghcr.io/${LS_USER}/${CONTAINER_NAME}:9 2>/dev/null | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\ -ls' || : ''' ,
8081 returnStdout : true ). trim()
@@ -803,6 +804,7 @@ pipeline {
803804 script{
804805 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
805806 env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
807+ env. CI_TEST_ATTEMPTED = ' true'
806808 }
807809 sh ''' #! /bin/bash
808810 set -e
@@ -1005,98 +1007,13 @@ EOF
10051007 ) '''
10061008 }
10071009 }
1008- // If this is a Pull request send the CI link as a comment on it
1009- stage(' Pull Request Comment' ) {
1010- when {
1011- not {environment name : ' CHANGE_ID' , value : ' ' }
1012- environment name : ' EXIT_STATUS' , value : ' '
1013- }
1014- steps {
1015- sh ''' #! /bin/bash
1016- # Function to retrieve JSON data from URL
1017- get_json() {
1018- local url="$1"
1019- local response=$(curl -s "$url")
1020- if [ $? -ne 0 ]; then
1021- echo "Failed to retrieve JSON data from $url"
1022- return 1
1023- fi
1024- local json=$(echo "$response" | jq .)
1025- if [ $? -ne 0 ]; then
1026- echo "Failed to parse JSON data from $url"
1027- return 1
1028- fi
1029- echo "$json"
1030- }
1031-
1032- build_table() {
1033- local data="$1"
1034-
1035- # Get the keys in the JSON data
1036- local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1037-
1038- # Check if keys are empty
1039- if [ -z "$keys" ]; then
1040- echo "JSON report data does not contain any keys or the report does not exist."
1041- return 1
1042- fi
1043-
1044- # Build table header
1045- local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1046-
1047- # Loop through the JSON data to build the table rows
1048- local rows=""
1049- for build in $keys; do
1050- local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1051- if [ "$status" = "true" ]; then
1052- status="✅"
1053- else
1054- status="❌"
1055- fi
1056- local row="| "$build" | "$status" |\\ n"
1057- rows="${rows}${row}"
1058- done
1059-
1060- local table="${header}${rows}"
1061- local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1062- echo "$escaped_table"
1063- }
1064-
1065- if [[ "${CI}" = "true" ]]; then
1066- # Retrieve JSON data from URL
1067- data=$(get_json "$CI_JSON_URL")
1068- # Create table from JSON data
1069- table=$(build_table "$data")
1070- echo -e "$table"
1071-
1072- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1073- -H "Accept: application/vnd.github.v3+json" \
1074- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1075- -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1076- else
1077- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1078- -H "Accept: application/vnd.github.v3+json" \
1079- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1080- -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1081- fi
1082- '''
1083-
1084- }
1085- }
10861010 }
10871011 /* ######################
1088- Send status to Discord
1012+ Comment on PR and Send status to Discord
10891013 ###################### */
10901014 post {
10911015 always {
1092- sh ''' #!/bin/bash
1093- rm -rf /config/.ssh/id_sign
1094- rm -rf /config/.ssh/id_sign.pub
1095- git config --global --unset gpg.format
1096- git config --global --unset user.signingkey
1097- git config --global --unset commit.gpgsign
1098- '''
1099- script{
1016+ script {
11001017 env. JOB_DATE = sh(
11011018 script : ''' date '+%Y-%m-%dT%H:%M:%S%:z' ''' ,
11021019 returnStdout : true ). trim()
@@ -1139,6 +1056,87 @@ EOF
11391056 "username": "Jenkins"}' ${BUILDS_DISCORD} '''
11401057 }
11411058 }
1059+ script {
1060+ if (env. GITHUBIMAGE =~ / lspipepr/ ){
1061+ if (env. CI_TEST_ATTEMPTED == " true" ){
1062+ sh ''' #! /bin/bash
1063+ # Function to retrieve JSON data from URL
1064+ get_json() {
1065+ local url="$1"
1066+ local response=$(curl -s "$url")
1067+ if [ $? -ne 0 ]; then
1068+ echo "Failed to retrieve JSON data from $url"
1069+ return 1
1070+ fi
1071+ local json=$(echo "$response" | jq .)
1072+ if [ $? -ne 0 ]; then
1073+ echo "Failed to parse JSON data from $url"
1074+ return 1
1075+ fi
1076+ echo "$json"
1077+ }
1078+
1079+ build_table() {
1080+ local data="$1"
1081+
1082+ # Get the keys in the JSON data
1083+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1084+
1085+ # Check if keys are empty
1086+ if [ -z "$keys" ]; then
1087+ echo "JSON report data does not contain any keys or the report does not exist."
1088+ return 1
1089+ fi
1090+
1091+ # Build table header
1092+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1093+
1094+ # Loop through the JSON data to build the table rows
1095+ local rows=""
1096+ for build in $keys; do
1097+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1098+ if [ "$status" = "true" ]; then
1099+ status="✅"
1100+ else
1101+ status="❌"
1102+ fi
1103+ local row="| "$build" | "$status" |\\ n"
1104+ rows="${rows}${row}"
1105+ done
1106+
1107+ local table="${header}${rows}"
1108+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1109+ echo "$escaped_table"
1110+ }
1111+
1112+ if [[ "${CI}" = "true" ]]; then
1113+ # Retrieve JSON data from URL
1114+ data=$(get_json "$CI_JSON_URL")
1115+ # Create table from JSON data
1116+ table=$(build_table "$data")
1117+ echo -e "$table"
1118+
1119+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1120+ -H "Accept: application/vnd.github.v3+json" \
1121+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1122+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1123+ else
1124+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1125+ -H "Accept: application/vnd.github.v3+json" \
1126+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1127+ -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1128+ fi
1129+ '''
1130+ }
1131+ }
1132+ }
1133+ sh ''' #!/bin/bash
1134+ rm -rf /config/.ssh/id_sign
1135+ rm -rf /config/.ssh/id_sign.pub
1136+ git config --global --unset gpg.format
1137+ git config --global --unset user.signingkey
1138+ git config --global --unset commit.gpgsign
1139+ '''
11421140 }
11431141 cleanup {
11441142 sh ''' #! /bin/bash
0 commit comments