@@ -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()
@@ -951,6 +952,7 @@ pipeline {
951952 script{
952953 env. CI_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /index.html'
953954 env. CI_JSON_URL = ' https://ci-tests.linuxserver.io/' + env. IMAGE + ' /' + env. META_TAG + ' /report.json'
955+ env. CI_TEST_ATTEMPTED = ' true'
954956 }
955957 sh ''' #! /bin/bash
956958 set -e
@@ -1159,98 +1161,13 @@ EOF
11591161 ) '''
11601162 }
11611163 }
1162- // If this is a Pull request send the CI link as a comment on it
1163- stage(' Pull Request Comment' ) {
1164- when {
1165- not {environment name : ' CHANGE_ID' , value : ' ' }
1166- environment name : ' EXIT_STATUS' , value : ' '
1167- }
1168- steps {
1169- sh ''' #! /bin/bash
1170- # Function to retrieve JSON data from URL
1171- get_json() {
1172- local url="$1"
1173- local response=$(curl -s "$url")
1174- if [ $? -ne 0 ]; then
1175- echo "Failed to retrieve JSON data from $url"
1176- return 1
1177- fi
1178- local json=$(echo "$response" | jq .)
1179- if [ $? -ne 0 ]; then
1180- echo "Failed to parse JSON data from $url"
1181- return 1
1182- fi
1183- echo "$json"
1184- }
1185-
1186- build_table() {
1187- local data="$1"
1188-
1189- # Get the keys in the JSON data
1190- local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1191-
1192- # Check if keys are empty
1193- if [ -z "$keys" ]; then
1194- echo "JSON report data does not contain any keys or the report does not exist."
1195- return 1
1196- fi
1197-
1198- # Build table header
1199- local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1200-
1201- # Loop through the JSON data to build the table rows
1202- local rows=""
1203- for build in $keys; do
1204- local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1205- if [ "$status" = "true" ]; then
1206- status="✅"
1207- else
1208- status="❌"
1209- fi
1210- local row="| "$build" | "$status" |\\ n"
1211- rows="${rows}${row}"
1212- done
1213-
1214- local table="${header}${rows}"
1215- local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1216- echo "$escaped_table"
1217- }
1218-
1219- if [[ "${CI}" = "true" ]]; then
1220- # Retrieve JSON data from URL
1221- data=$(get_json "$CI_JSON_URL")
1222- # Create table from JSON data
1223- table=$(build_table "$data")
1224- echo -e "$table"
1225-
1226- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1227- -H "Accept: application/vnd.github.v3+json" \
1228- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1229- -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1230- else
1231- curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1232- -H "Accept: application/vnd.github.v3+json" \
1233- "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1234- -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1235- fi
1236- '''
1237-
1238- }
1239- }
12401164 }
12411165 /* ######################
1242- Send status to Discord
1166+ Comment on PR and Send status to Discord
12431167 ###################### */
12441168 post {
12451169 always {
1246- sh ''' #!/bin/bash
1247- rm -rf /config/.ssh/id_sign
1248- rm -rf /config/.ssh/id_sign.pub
1249- git config --global --unset gpg.format
1250- git config --global --unset user.signingkey
1251- git config --global --unset commit.gpgsign
1252- '''
1253- script{
1170+ script {
12541171 env. JOB_DATE = sh(
12551172 script : ''' date '+%Y-%m-%dT%H:%M:%S%:z' ''' ,
12561173 returnStdout : true ). trim()
@@ -1293,6 +1210,87 @@ EOF
12931210 "username": "Jenkins"}' ${BUILDS_DISCORD} '''
12941211 }
12951212 }
1213+ script {
1214+ if (env. GITHUBIMAGE =~ / lspipepr/ ){
1215+ if (env. CI_TEST_ATTEMPTED == " true" ){
1216+ sh ''' #! /bin/bash
1217+ # Function to retrieve JSON data from URL
1218+ get_json() {
1219+ local url="$1"
1220+ local response=$(curl -s "$url")
1221+ if [ $? -ne 0 ]; then
1222+ echo "Failed to retrieve JSON data from $url"
1223+ return 1
1224+ fi
1225+ local json=$(echo "$response" | jq .)
1226+ if [ $? -ne 0 ]; then
1227+ echo "Failed to parse JSON data from $url"
1228+ return 1
1229+ fi
1230+ echo "$json"
1231+ }
1232+
1233+ build_table() {
1234+ local data="$1"
1235+
1236+ # Get the keys in the JSON data
1237+ local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
1238+
1239+ # Check if keys are empty
1240+ if [ -z "$keys" ]; then
1241+ echo "JSON report data does not contain any keys or the report does not exist."
1242+ return 1
1243+ fi
1244+
1245+ # Build table header
1246+ local header="| Tag | Passed |\\ n| --- | --- |\\ n"
1247+
1248+ # Loop through the JSON data to build the table rows
1249+ local rows=""
1250+ for build in $keys; do
1251+ local status=$(echo "$data" | jq -r ".[\\ "$build\\ "].test_success")
1252+ if [ "$status" = "true" ]; then
1253+ status="✅"
1254+ else
1255+ status="❌"
1256+ fi
1257+ local row="| "$build" | "$status" |\\ n"
1258+ rows="${rows}${row}"
1259+ done
1260+
1261+ local table="${header}${rows}"
1262+ local escaped_table=$(echo "$table" | sed 's/\" /\\\\ "/g')
1263+ echo "$escaped_table"
1264+ }
1265+
1266+ if [[ "${CI}" = "true" ]]; then
1267+ # Retrieve JSON data from URL
1268+ data=$(get_json "$CI_JSON_URL")
1269+ # Create table from JSON data
1270+ table=$(build_table "$data")
1271+ echo -e "$table"
1272+
1273+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1274+ -H "Accept: application/vnd.github.v3+json" \
1275+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1276+ -d "{\\ "body\\ ": \\ "I am a bot, here are the test results for this PR: \\ n${CI_URL}\\ n${SHELLCHECK_URL}\\ n${table}\\ "}"
1277+ else
1278+ curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
1279+ -H "Accept: application/vnd.github.v3+json" \
1280+ "https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
1281+ -d "{\\ "body\\ ": \\ "I am a bot, here is the pushed image/manifest for this PR: \\ n\\ n\\ `${GITHUBIMAGE}:${META_TAG}\\ `\\ "}"
1282+ fi
1283+ '''
1284+ }
1285+ }
1286+ }
1287+ sh ''' #!/bin/bash
1288+ rm -rf /config/.ssh/id_sign
1289+ rm -rf /config/.ssh/id_sign.pub
1290+ git config --global --unset gpg.format
1291+ git config --global --unset user.signingkey
1292+ git config --global --unset commit.gpgsign
1293+ '''
12961294 }
12971295 cleanup {
12981296 sh ''' #! /bin/bash
0 commit comments