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