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.
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.
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.
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.
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.
Available targets:
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
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
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
project's build.xml never builds or uploads those itself.
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
${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
${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.
Adding a new server: add
<target name="install-scripts(@new-server-hostname)" description="...">
<upload-scripts host="new-server-hostname"/>
</target>
<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}"/>
<verify-upgrade host="new-server-hostname"/>
</target>
below — the shared sportrum user/key/port above cover it already, nothing
else to configure here.