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