Closed jpschewe closed 1 year ago
One can get the tar.gz with
url="https://jenkins.mtu.net/job/FLL-SW/job/main/lastSuccessfulBuild/artifact/$(curl --silent https://jenkins.mtu.net/job/FLL-SW/job/main/lastSuccessfulBuild/api/json | jq -r '.artifacts[].relativePath' | grep distributions | grep linux)"
curl --silent -O "${url}"
Get filename with
echo ${url} | awk -F/ '{print $NF}'
tar -xzf ${filename}
dirname=$(basename "${filename}" .tar.gz)
Can use this using polling
#!/bin/sh
debug() { ! "${log_debug-false}" || log "DEBUG: $*" >&2; }
log() { printf '%s\n' "$*"; }
warn() { log "WARNING: $*" >&2; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
try() { "$@" || fatal "'$@' failed"; }
mydir=$(cd "$(dirname "$0")" && pwd -L) || fatal "Unable to determine script directory"
cleanup() {
debug "In cleanup"
}
trap 'cleanup' INT TERM EXIT
fetch_extract() {
try curl --silent -O "${url}"
try tar -xzf ${filename}
try ln -s "${dirname}" current
}
release_file=$(curl --silent https://jenkins.mtu.net/job/FLL-SW/job/main/lastSuccessfulBuild/api/json | jq -r '.artifacts[].relativePath' | grep distributions | grep linux)
url="https://jenkins.mtu.net/job/FLL-SW/job/main/lastSuccessfulBuild/artifact/${release_file}"
filename=$(echo ${url} | awk -F/ '{print $NF}')
dirname=$(basename "${filename}" .tar.gz)
if [ -e current ]; then
if [ -L current ]; then
target_link=$(readlink current)
if [ "${target_link}" = "${dirname}" ]; then
debug "New release is the same as the current, no change needed"
exit 0
fi
try rm current
fetch_extract
cd current
log ../launch.sh --migrate ../${target_link}
else
fatal "current exists and is NOT a symlink"
fi
else
fetch_extract
try cd current
log ../launch.sh
fi
Still need to kill off the existing process.
Have a shell script that kills the process and starts a new one. One issue is that I don't have the standard output anywhere, although I'm not sure if I care.
I have a script setup and running on the server. I should have a way for old versions to be removed so that the disk doesn't get filled up.
Also consider running as a service.
I created a service for fll2 today. See how this goes.
I've got services for all of the sites up and a service for the deploy script.
Have all builds on main automatically update demo.fll-sw.mtu.net or another similar site.