mirror of
https://github.com/linuxserver/docker-code-server.git
synced 2024-12-22 18:37:43 +01:00
Bot Updating Templated Files
This commit is contained in:
parent
b8bcdc44b7
commit
66da21de61
91
Jenkinsfile
vendored
91
Jenkinsfile
vendored
@ -39,10 +39,11 @@ pipeline {
|
||||
// Setup all the basic environment variables needed for the build
|
||||
stage("Set ENV Variables base"){
|
||||
steps{
|
||||
sh '''docker pull quay.io/skopeo/stable:v1 || : '''
|
||||
script{
|
||||
env.EXIT_STATUS = ''
|
||||
env.LS_RELEASE = sh(
|
||||
script: '''docker run --rm ghcr.io/linuxserver/alexeiled-skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''',
|
||||
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' || : ''',
|
||||
returnStdout: true).trim()
|
||||
env.LS_RELEASE_NOTES = sh(
|
||||
script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''',
|
||||
@ -228,7 +229,7 @@ pipeline {
|
||||
script{
|
||||
env.SHELLCHECK_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/shellcheck-result.xml'
|
||||
}
|
||||
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-shellcheck/master/checkrun.sh | /bin/bash'''
|
||||
sh '''curl -sL https://raw.githubusercontent.com/linuxserver/docker-jenkins-builder/master/checkrun.sh | /bin/bash'''
|
||||
sh '''#! /bin/bash
|
||||
docker run --rm \
|
||||
-v ${WORKSPACE}:/mnt \
|
||||
@ -376,6 +377,26 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
// If this is a master build check the S6 service file perms
|
||||
stage("Check S6 Service file Permissions"){
|
||||
when {
|
||||
branch "master"
|
||||
environment name: 'CHANGE_ID', value: ''
|
||||
environment name: 'EXIT_STATUS', value: ''
|
||||
}
|
||||
steps {
|
||||
script{
|
||||
sh '''#! /bin/bash
|
||||
WRONG_PERM=$(find ./ -path "./.git" -prune -o \\( -name "run" -o -name "finish" -o -name "check" \\) -not -perm -u=x,g=x,o=x -print)
|
||||
if [[ -n "${WRONG_PERM}" ]]; then
|
||||
echo "The following S6 service files are missing the executable bit; canceling the faulty build: ${WRONG_PERM}"
|
||||
exit 1
|
||||
else
|
||||
echo "S6 service file perms look good."
|
||||
fi '''
|
||||
}
|
||||
}
|
||||
}
|
||||
/* #######################
|
||||
GitLab Mirroring
|
||||
####################### */
|
||||
@ -668,6 +689,7 @@ pipeline {
|
||||
]) {
|
||||
script{
|
||||
env.CI_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/index.html'
|
||||
env.CI_JSON_URL = 'https://ci-tests.linuxserver.io/' + env.IMAGE + '/' + env.META_TAG + '/report.json'
|
||||
}
|
||||
sh '''#! /bin/bash
|
||||
set -e
|
||||
@ -694,8 +716,6 @@ pipeline {
|
||||
-e WEB_SCREENSHOT=\"${CI_WEB}\" \
|
||||
-e WEB_AUTH=\"${CI_AUTH}\" \
|
||||
-e WEB_PATH=\"${CI_WEBPATH}\" \
|
||||
-e DO_REGION="ams3" \
|
||||
-e DO_BUCKET="lsio-ci" \
|
||||
-t ghcr.io/linuxserver/ci:latest \
|
||||
python3 test_build.py'''
|
||||
}
|
||||
@ -949,8 +969,67 @@ pipeline {
|
||||
environment name: 'EXIT_STATUS', value: ''
|
||||
}
|
||||
steps {
|
||||
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/issues/${PULL_REQUEST}/comments \
|
||||
-d '{"body": "I am a bot, here are the test results for this PR: \\n'${CI_URL}' \\n'${SHELLCHECK_URL}'"}' '''
|
||||
sh '''#! /bin/bash
|
||||
# Function to retrieve JSON data from URL
|
||||
get_json() {
|
||||
local url="$1"
|
||||
local response=$(curl -s "$url")
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to retrieve JSON data from $url"
|
||||
return 1
|
||||
fi
|
||||
local json=$(echo "$response" | jq .)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to parse JSON data from $url"
|
||||
return 1
|
||||
fi
|
||||
echo "$json"
|
||||
}
|
||||
|
||||
build_table() {
|
||||
local data="$1"
|
||||
|
||||
# Get the keys in the JSON data
|
||||
local keys=$(echo "$data" | jq -r 'to_entries | map(.key) | .[]')
|
||||
|
||||
# Check if keys are empty
|
||||
if [ -z "$keys" ]; then
|
||||
echo "JSON report data does not contain any keys or the report does not exist."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Build table header
|
||||
local header="| Tag | Passed |\\n| --- | --- |\\n"
|
||||
|
||||
# Loop through the JSON data to build the table rows
|
||||
local rows=""
|
||||
for build in $keys; do
|
||||
local status=$(echo "$data" | jq -r ".[\\"$build\\"].test_success")
|
||||
if [ "$status" = "true" ]; then
|
||||
status="✅"
|
||||
else
|
||||
status="❌"
|
||||
fi
|
||||
local row="| "$build" | "$status" |\\n"
|
||||
rows="${rows}${row}"
|
||||
done
|
||||
|
||||
local table="${header}${rows}"
|
||||
local escaped_table=$(echo "$table" | sed 's/\"/\\\\"/g')
|
||||
echo "$escaped_table"
|
||||
}
|
||||
|
||||
# Retrieve JSON data from URL
|
||||
data=$(get_json "$CI_JSON_URL")
|
||||
# Create table from JSON data
|
||||
table=$(build_table "$data")
|
||||
echo -e "$table"
|
||||
|
||||
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/$LS_USER/$LS_REPO/issues/$PULL_REQUEST/comments" \
|
||||
-d "{\\"body\\": \\"I am a bot, here are the test results for this PR: \\n${CI_URL}\\n${SHELLCHECK_URL}\\n${table}\\"}"'''
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user