Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<project name= "sportrum-deploy" default= "help" basedir= "." >
<!-- Reuses the SAME account/key/port the sportrum webapp's own
build.xml already uses for its "release-all" target (there: scp
sportrum.war/manager.zip to sportrum@<host > :2222 with
${confdir}/sportrum_key_new) — not a separate, more-restricted
deploy account like xzpect-timer's xztimer user.
That's deliberate, not a shortcut: unlike xztimer (which can only
ever write into one directory tree), upgrade.sh needs real
privilege on this server — stopping/starting Tomcat, pg_dump,
running manager-exec.sh's DB migrations — all via the sportrum
container user's NOPASSWD sudo (see sportrum-ansible's
files/app/Dockerfile). A second, "dedicated" deploy account here
would just end up needing the exact same sudo rights, so there's
nothing to gain from provisioning one — it'd be one more key to
manage for no reduction in what a compromise of it could do. -->
<property name= "deploy.user" value= "sportrum" />
<property name= "deploy.ssh.port" value= "2222" />
<!-- Same physical private key the sportrum webapp project's
release-all target uses (there: ${confdir}/sportrum_key_new) — set
deploy.keyfile in build.local.properties to point at that exact
file if it doesn't live at this default path for you. Sharing one
key across both projects is intentional: it's the same account on
the same server either way, so a second key would just be one more
thing to keep in sync (and to revoke, if it's ever compromised). -->
<property name= "deploy.keyfile" value= "${user.home}/.ssh/sportrum_key_new" />
<property name= "deploy.knownhosts" value= "${user.home}/.ssh/known_hosts" />
<!-- Local, untracked overrides — put deploy.keyfile=... or
deploy.key.passphrase=... in here (see .gitignore) rather than
typing either in plain text anywhere that gets committed. Missing
file is fine; Ant just skips it. -->
<property file= "${basedir}/build.local.properties" />
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<!-- Default so an unencrypted key doesn't get passed the LITERAL
string "${deploy.key.passphrase}" as its passphrase - an unset
Ant property is left as its own ${...} text rather than becoming
empty, which is exactly the kind of thing that fails silently
confusingly deep in a JSch stack trace. Confirmed this is a real
gotcha, not a hypothetical one, by testing an unset reference
directly. Set the real value in build.local.properties if your
key needs one; this default only applies when nothing overrides
it. -->
<property name= "deploy.key.passphrase" value= "" />
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<!-- Same Windows - vs - WSL ${user.home} gotcha documented at length in
xzpect-timer/build.xml: which home directory this resolves to
depends entirely on what actually runs the JVM invoking Ant
(native Windows vs. WSL/git-bash are separate filesystems with
separate ~/.ssh dirs, nothing shared automatically). Fails fast
with a clear pointer back here instead of a bare
"com.jcraft.jsch.JSchException: java.io.FileNotFoundException"
deep in an scp/sshexec stack trace. -->
<available file= "${deploy.keyfile}" property= "deploy.keyfile.exists" />
<fail unless= "deploy.keyfile.exists" >
The SSH deploy key isn't where this build expects it:
${deploy.keyfile}
If it already works from a different shell (e.g. WSL/git-bash) but not from
here, this is almost certainly the Windows-vs-WSL home directory split
described in xzpect-timer/build.xml's comments, not a missing key. Copy it
(and known_hosts, checked separately below) over from wherever it already
works, e.g. from a WSL bash shell:
mkdir -p /mnt/c/Users/< you> /.ssh
cp ~/.ssh/sportrum_key_new /mnt/c/Users/< you> /.ssh/
If you keep this key somewhere else entirely (e.g. alongside the sportrum
webapp project's confdir/), point deploy.keyfile at it in
build.local.properties instead of moving the file.
</fail>
<available file= "${deploy.knownhosts}" property= "deploy.knownhosts.exists" />
<fail unless= "deploy.knownhosts.exists" >
known_hosts isn't where this build expects it:
${deploy.knownhosts}
Same Windows-vs-WSL split as the deploy key above most likely applies here
too. Copy or append it over from wherever it already works (append, don't
overwrite, if the destination already has unrelated entries you want to
keep):
cat ~/.ssh/known_hosts > > /mnt/c/Users/< you> /.ssh/known_hosts
If this is truly the first time connecting to the target server from
anywhere, SSH in manually once first (e.g.
"ssh -p ${deploy.ssh.port} ${deploy.user}@< server> ") and accept its host
key interactively — this build's scp/sshexec tasks deliberately don't
auto-trust unknown host keys.
</fail>
<!-- Ant's scp/sshexec tasks need JSch on the classpath. The jar itself
is checked into the repo (lib.build/, not lib/, since it's only
ever needed to RUN this build — nothing here ships to the server)
so there's nothing to download. See lib.build/README.md for why
this project uses the -lib approach rather than the
ant-classloadertask trick the sportrum webapp's own build.xml
uses. -->
<path id= "deploy.classpath" >
<fileset dir= "${basedir}/lib.build" includes= "*.jar" />
</path>
<!-- classpathref alone is NOT enough on every machine — see
xzpect-timer/build.xml's comment above its identical check for the
full explanation (short version: a system ant-optional/ant-jsch
package, if one happens to be installed, gets loaded instead, and
then can't see this project's own jsch jar at all no matter what
classpathref says). -->
<available classname= "com.jcraft.jsch.Logger" property= "jsch.on.core.classpath" />
<fail unless= "jsch.on.core.classpath" >
This build's scp/sshexec targets need JSch on ANT'S OWN classpath, not just
this project's taskdef classpathref (see lib.build/README.md). Re-run with
-lib, e.g.:
ant -lib lib.build "deploy(@local.sportrum.se)"
Running from Eclipse instead? Add lib.build/jsch-*.jar under Window ->
Preferences -> Ant -> Runtime -> Classpath -> Ant Home Entries — same fix.
</fail>
<taskdef name= "scp"
classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp"
classpathref="deploy.classpath"/>
<taskdef name= "sshexec"
classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
classpathref="deploy.classpath"/>
<!-- Where this repo's own control scripts live inside the app
container. Chosen fresh (nothing was already using a fixed path
here) — a directory named after this repo, under the sportrum
user's own home, alongside webapp/ and backup/. -->
<property name= "deploy.remotepath" value= "/home/sportrum/sportrum-deploy/" />
<!-- install - scripts(@host) (see below) always re - uploads these before
anything runs, so the server can never end up running a
hand-edited or stale copy that's drifted from what's actually in
this repo — the same reasoning as xzpect-timer re-installing
deploy-pwa.sh on every install. Deliberately NOT emergency-
storeall.sh/nightly-storeall.sh: those are cron-driven and live on
the server independently of any given upgrade; bundling them into
every deploy would mean an unrelated deploy could silently change
what a running cron job does mid-cycle. -->
<macrodef name= "upload-scripts" >
<attribute name= "host" />
<sequential >
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
command="mkdir -p ${deploy.remotepath}"/>
<echo message= "Syncing upgrade.sh and friends to ${deploy.user}@@@{host}:${deploy.remotepath}..." />
<scp todir= "${deploy.user}@@@{host}:${deploy.remotepath}"
port="${deploy.ssh.port}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}">
<fileset dir= "${basedir}" >
<include name= "upgrade.sh" />
<include name= "upgrade-cmds.sh" />
<include name= "upgrade-funs.sh" />
<include name= "tomcat_ctl.sh" />
<include name= "restart.sh" />
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<include name= "check-schema-diff.sh" />
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
</fileset>
</scp>
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
command="chmod +x ${deploy.remotepath}*.sh"/>
<echo message= "Scripts synced. Nothing has run yet — run "ant deploy(@@@{host})", or SSH in and run ${deploy.remotepath}upgrade.sh yourself, to actually upgrade." />
</sequential>
</macrodef>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<!-- Both deploy modes below deliberately do NOT build or upload
sportrum.war/manager.zip themselves — they assume those are
ALREADY sitting at /home/sportrum/webapp/sportrum.war and
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
/home/sportrum/manager.zip from a prior run of the sportrum webapp
project's own "ant release-all" (its release-all target scps them
there). That's the split the two projects deliberately keep: the
webapp project's build.xml builds and installs the war; this
project's build.xml does the actual deploy. Forgetting to run
release-all first isn't silent, though — upgrade-cmds.sh's own
"unzip -q sportrum.war -d sportrum" fails loudly if the file isn't
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
there, and failonerror below makes that failure fail the Ant
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
target too, not just get logged and ignored. -->
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<!-- Verifies the "no pending DB schema change" assumption BEFORE
anything live is touched - see check-schema-diff.sh's own header
comment for why this is safe to run standalone (it only reads a
staged, not-yet-installed copy of manager.zip and the live DB,
never the running webapp/Tomcat). haltonerror="true" (the
default, for hotfix-code) fails the whole Ant build the moment
the remote check comes back non-clean, before Tomcat is ever
stopped - a wrong assumption there costs zero downtime.
haltonerror="false" (used by migrate) logs the same diff for
visibility without blocking, since migrate is exactly the mode
where a schema difference is expected, not a sign anything is
wrong. Either way, sshexec streams the remote command's output as
it runs, so the diff is visible in the build log regardless of
whether it ends up blocking anything. -->
<macrodef name= "run-schema-check" >
<attribute name= "host" />
<attribute name= "haltonerror" default= "true" />
<sequential >
<echo message= "Checking for pending schema differences against @{host} (not touching the live webapp or Tomcat)..." />
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
command="${deploy.remotepath}check-schema-diff.sh /home/sportrum/manager.zip"
failonerror="@{haltonerror}"/>
</sequential>
</macrodef>
<!-- hotfix - code: no SQL backup, no DB migration - see upgrade.sh's own
header comment for the full rationale. Only ever reached after
run-schema-check above has already confirmed there's nothing
pending, so upgrade-cmds.sh isn't guessing when it skips the DB
step. -->
<macrodef name= "run-hotfix-code" >
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<attribute name= "host" />
<sequential >
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<echo message= "Running upgrade.sh hotfix-code on @{host} — stops Tomcat, backs up the current webapp/logs (no SQL dump - no schema change to protect against), installs the new sportrum.war, restarts Tomcat. No DB migration runs..." />
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
command="cd ${deploy.remotepath} & & ./upgrade.sh hotfix-code"
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
failonerror="true"/>
</sequential>
</macrodef>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<!-- migrate: full careful path, including the tagged, never - pruned
before/after backup and DB migration transcript under
backup/migrations/<tag > / on the server - see upgrade-cmds.sh's own
comments for exactly what gets captured. -->
<macrodef name= "run-migrate" >
<attribute name= "host" />
<attribute name= "tag" />
<sequential >
<echo message= "Running upgrade.sh migrate on @{host} (tag: @{tag}) — stops Tomcat, takes a tagged before-snapshot (kept indefinitely) plus the regular short-lived backup, installs the new sportrum.war/manager.zip, runs the DB migration with its transcript saved under the tag, takes a tagged after-snapshot, restarts Tomcat..." />
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
command="cd ${deploy.remotepath} & & ./upgrade.sh migrate '@{tag}'"
failonerror="true"/>
</sequential>
</macrodef>
<!-- Resolves deploy.tag for migrate(@host): <git - version>[ - <label>].
The git-version half is read back off the sportrum.war ALREADY
uploaded by the webapp project's own release-all - see this
project's README for the WEB-INF/VERSION snippet that project's
build.xml needs for this to work. WEB-INF/, not the WAR root,
since anything outside WEB-INF/ is directly servable over HTTP by
Tomcat and a commit hash shouldn't be publicly fetchable.
The label half is optional and interactive by design (Ant's
<input > task, confirmed empirically: it skips prompting entirely
if deploy.label is already set, e.g. via -Ddeploy.label=... for a
scripted run - and confirmed working from a plain piped/typed
stdin). Hit enter to skip it; the git version alone is already a
complete, unique, non-blank tag on its own. -->
<macrodef name= "resolve-migration-tag" >
<attribute name= "host" />
<sequential >
<sshexec host= "@{host}"
port="${deploy.ssh.port}"
username="${deploy.user}"
keyfile="${deploy.keyfile}"
passphrase="${deploy.key.passphrase}"
knownhosts="${deploy.knownhosts}"
command="unzip -p /home/sportrum/webapp/sportrum.war WEB-INF/VERSION | tr -d '\n'"
outputproperty="deploy.gitversion"
failonerror="true"/>
<!-- tr - d strips any trailing newline the webapp build's echo/
file-write may have left in WEB-INF/VERSION - whether or
not it did isn't this project's business to assume either
way, and a stray newline landing in a directory name would
be a much stranger failure to debug than this one-liner is
to write. -->
<condition property= "deploy.gitversion.blank" >
<equals arg1= "${deploy.gitversion}" arg2= "" />
</condition>
<fail if= "deploy.gitversion.blank" >
Couldn't read WEB-INF/VERSION out of the sportrum.war on @{host}. Either
"ant release-all" hasn't been run against this server yet, or the webapp
project's build.xml doesn't embed WEB-INF/VERSION yet - see this project's
README for the snippet it needs.
</fail>
<input message= "Optional short label for this migration (e.g. 'invoice-table') - press Enter to skip:" addproperty= "deploy.label" />
<condition property= "deploy.label.unsafe" >
<and >
<not > <equals arg1= "${deploy.label}" arg2= "" /> </not>
<not > <matches pattern= "^[A-Za-z0-9._-]*$" string= "${deploy.label}" /> </not>
</and>
</condition>
<fail if= "deploy.label.unsafe" >
The migration label can only contain letters, digits, dots, dashes, and
underscores (got: "${deploy.label}") - it becomes part of a directory name
on the server. Run again without spaces or other punctuation.
</fail>
<!-- Set - once semantics do the branching here: this only takes
effect (and only when deploy.tag isn't already set, e.g.
via -Ddeploy.tag=... for a fully scripted run) when the
label is non-blank; the plain <property > right after it
is the fallback for a blank label, since it won't
override a value the condition above already set.
Confirmed both branches empirically before relying on
this. -->
<condition property= "deploy.tag" value= "${deploy.gitversion}-${deploy.label}" >
<not > <equals arg1= "${deploy.label}" arg2= "" /> </not>
</condition>
<property name= "deploy.tag" value= "${deploy.gitversion}" />
<echo message= "Migration tag: ${deploy.tag}" />
</sequential>
</macrodef>
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<!-- Post - deploy check, same idea as xzpect - timer's verify - pwa — the app
itself is reverse-proxied at the domain root by Caddy (see
sportrum-ansible's templates/Caddyfile.j2), so @{host} IS the URL
to check, no path suffix needed. -->
<macrodef name= "verify-upgrade" >
<attribute name= "host" />
<sequential >
<echo message= "Verifying https://@{host}/ responds..." />
<get src= "https://@{host}/"
dest="${java.io.tmpdir}/sportrum-deploy-check.html"
verbose="false"/>
<echo message= "OK — @{host} responded. Worth also checking @{host}'s Tomcat/manager logs by hand to confirm the DB migration itself completed cleanly — an HTTP 200 here only means Tomcat came back up, not that the upgrade's migration step succeeded." />
</sequential>
</macrodef>
<!-- No - op default so running plain "ant" never touches a live server by accident. -->
<target name= "help" >
<echo > Available targets:
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
ant "install-scripts(@local.sportrum.se)" - sync this repo's control scripts to the server (does NOT run anything)
ant "hotfix-code(@local.sportrum.se)" - for a Java/resource change with NO DB migration
ant "migrate(@local.sportrum.se)" - for a change that DOES migrate the DB schema/data
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
Before the FIRST run against any given server: ssh -p ${deploy.ssh.port} ${deploy.user}@< that server>
once, interactively (accept the host key, then Ctrl+D) so ${deploy.knownhosts}
already has it — these targets do not auto-trust unknown host keys.
Also run the sportrum webapp project's own "ant release-all" FIRST, against
the same server — it builds and uploads sportrum.war/manager.zip, which
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
upgrade.sh (run by both deploy targets here) expects to already be sitting
at /home/sportrum/webapp/sportrum.war and /home/sportrum/manager.zip. This
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
project's build.xml never builds or uploads those itself.
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
Two deploy targets, not one, because the two scenarios genuinely need
different handling - see upgrade.sh's own header comment for the full
rationale:
- hotfix-code(@server): for a change with no DB migration. First runs
check-schema-diff.sh against the server and HARD-FAILS if it finds any
pending schema difference, before Tomcat is ever touched - a wrong
assumption here costs zero downtime instead of a broken mid-upgrade
state. Then: WAR+logs backup only (no SQL dump - nothing to protect
against), install the new sportrum.war, restart Tomcat (still needed;
class files may have changed). No manager-exec.sh runs at all.
- migrate(@server): for a change that DOES touch the DB. Prompts for a
tag - the git version already embedded in sportrum.war's
WEB-INF/VERSION (see this project's README for the webapp project's
own build.xml needs), plus an optional short label - then runs the
same schema check as above but only logs the result rather than
blocking (a diff here is expected, not a sign anything's wrong). Then:
full SQL+WAR+logs backup (the regular short-lived tier AND an
indefinitely-kept copy under backup/migrations/< tag> / on the
server), install the new sportrum.war/manager.zip, run the DB
migration (its full transcript saved next to the tagged backup),
take a matching post-migration snapshot, restart Tomcat.
Both depend on install-scripts(@server) first, so the server is always
running this repo's current scripts, never a stale hand-copied version.
A third scenario - a template-only hotfix needing no Tomcat restart at all
- is intentionally not implemented as a target yet; see upgrade.sh's
header comment for why.
Because each deploy is just upgrade.sh living on the server (at
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
${deploy.remotepath}), you don't need ant for it at all if you'd rather
not: run "ant install-scripts(@server)" whenever you like, then SSH in as
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
${deploy.user} and run "./upgrade.sh hotfix-code", "./upgrade.sh migrate
< tag> ", or "./restart.sh" (a plain restart, no upgrade) yourself, at
whatever moment you choose - check-schema-diff.sh is there too, if you
want to run that check by hand first.
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
Adding a new server: add
< target name="install-scripts(@new-server-hostname)" description="...">
< upload-scripts host="new-server-hostname"/>
< /target>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
< target name="hotfix-code(@new-server-hostname)" depends="install-scripts(@new-server-hostname)" description="...">
< run-schema-check host="new-server-hostname"/>
< run-hotfix-code host="new-server-hostname"/>
< verify-upgrade host="new-server-hostname"/>
< /target>
< target name="migrate(@new-server-hostname)" depends="install-scripts(@new-server-hostname)" description="...">
< resolve-migration-tag host="new-server-hostname"/>
< run-schema-check host="new-server-hostname" haltonerror="false"/>
< run-migrate host="new-server-hostname" tag="${deploy.tag}"/>
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
< verify-upgrade host="new-server-hostname"/>
< /target>
below — the shared sportrum user/key/port above cover it already, nothing
else to configure here.</echo>
</target>
<target name= "install-scripts(@local.sportrum.se)"
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
description="Upload upgrade.sh, upgrade-cmds.sh, upgrade-funs.sh, tomcat_ctl.sh, restart.sh, and check-schema-diff.sh to local.sportrum.se. Does NOT run anything.">
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<upload-scripts host= "local.sportrum.se" />
</target>
Replace flag-based upgrade.sh with named migrate/hotfix-code modes
upgrade.sh's old -f/-w/-s flags let you skip a backup or the DB
migration independently of each other, with nothing to stop a
combination that didn't actually make sense for the change being
shipped. Replace them with two named modes:
- migrate: for a change that touches the DB. Full SQL+WAR+logs
backup, both the existing short-lived tier and a new, never-pruned
backup/migrations/<tag>/ tier (before/after snapshot plus the full
DB migration transcript, tee'd from manager-exec.sh). The tag comes
from build.xml's migrate(@host) target: the git version already
embedded in sportrum.war's WEB-INF/VERSION (see README for the
webapp project's own build.xml snippet this needs), plus an
optional interactive label via Ant's <input> task.
- hotfix-code: for a Java/resource change with no DB migration. WAR
backup only (no SQL dump, no indefinite copy), no manager-exec.sh
at all. Only reached after check-schema-diff.sh - a new script that
runs ICPManager's diff-meta against a staged, not-yet-installed
copy of manager.zip, entirely independent of the live webapp/Tomcat
- has already confirmed there's no pending schema change, hard
gating build.xml's hotfix-code(@host) target before Tomcat is ever
touched.
A third scenario (template-only hotfix, no Tomcat restart at all) is
intentionally not implemented yet - which files count as "templates"
and how they'd sync into the live webapp directory is still an open
question.
Dropped without replacement: the old storeonly (-s) mode and the
"leave Tomcat stopped" action argument - undocumented, flag-only
behaviors nothing here exercised, easy to reintroduce as an explicit
mode later if actually needed.
Also fixes a real gap found while testing this: a failed migration
left upgrade-cmds.sh exiting 0, which would have made upgrade.sh (and
an Ant sshexec with failonerror) report success on a failed DB
migration. And build.xml's deploy.key.passphrase had no default,
which (confirmed by testing) left the literal string
"${deploy.key.passphrase}" as the passphrase for anyone not setting
it in build.local.properties.
Verified with a full fake fixture (fake pg_dump, fake manager.zip/
manager-exec.sh, fake sportrum.war): migrate success, migrate
collision-refusal on a reused tag, migrate failure preserving the
before-snapshot without pruning, hotfix-code skipping the SQL/DB
steps, and check-schema-diff.sh's three exit codes (clean/
differences/broken) all behave as designed. Ant-side tag assembly
(<input> skip-when-preset, blank-label fallback, unsafe-character
rejection) verified the same way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 20:00:35 +00:00
<target name= "hotfix-code(@local.sportrum.se)" depends= "install-scripts(@local.sportrum.se)"
description="For a Java/resource change with NO DB migration. Verifies no schema change is pending (hard fail if one is, before Tomcat is touched), then runs upgrade.sh hotfix-code on local.sportrum.se, then confirms https://local.sportrum.se/ responds.">
<run-schema-check host= "local.sportrum.se" />
<run-hotfix-code host= "local.sportrum.se" />
<verify-upgrade host= "local.sportrum.se" />
</target>
<target name= "migrate(@local.sportrum.se)" depends= "install-scripts(@local.sportrum.se)"
description="For a change that DOES migrate the DB. Resolves a tag (git version from sportrum.war's WEB-INF/VERSION + optional label), logs the pending schema diff, then runs upgrade.sh migrate on local.sportrum.se (tagged before/after backup kept indefinitely, DB migration with saved transcript), then confirms https://local.sportrum.se/ responds.">
<resolve-migration-tag host= "local.sportrum.se" />
<run-schema-check host= "local.sportrum.se" haltonerror= "false" />
<run-migrate host= "local.sportrum.se" tag= "${deploy.tag}" />
Add Ant deploy target, mirroring xzpect-timer's build.xml pattern
install-scripts(@host) syncs upgrade.sh/upgrade-cmds.sh/upgrade-funs.sh/
tomcat_ctl.sh/restart.sh to the server so it never runs a stale
hand-copied version; deploy(@host) runs that first, then sshexecs
upgrade.sh itself, then checks the site responds.
Reuses the sportrum webapp project's own account (sportrum@host:2222,
same key as its release-all target) rather than a separate dedicated
deploy user like xzpect-timer's xztimer - upgrade.sh needs real
privilege (Tomcat control, pg_dump, DB migrations via the container's
NOPASSWD sudo), so a second account would need the same rights anyway.
This project's build.xml never builds or uploads sportrum.war/
manager.zip itself; that's release-all's job in the webapp project -
this one only does the actual deploy once those are already staged.
Uses the -lib lib.build / checked-in jsch jar approach for the JSch
classpath gotcha, same as xzpect-timer, rather than the webapp
project's ant-classloadertask trick - that one's JDK-8-only, and this
build isn't guaranteed to run under the same JDK as the webapp's.
Verified end-to-end short of an actual server: ant -p and ant help
both hit the documented pre-flight failures correctly (missing key,
missing JSch on classpath) before -lib is added, succeed after; with
a real generated key, sshexec correctly gets past key-parsing and
attempts a real connection.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-30 18:41:12 +00:00
<verify-upgrade host= "local.sportrum.se" />
</target>
</project>