Delete old builds from the server when deploying a new one
Summary
- The
copy-artifactjob copied a new timestampedmtsa-build.<timestamp>.jarto/var/www/mtsa/download/builds/on every master pipeline and never removed old ones, so the server was filling up. - After copying the new jar and updating the
mtsa-latest-build.jarsymlink, the job now deletes all but theKEEP_BUILDSmost recent builds (set to 5 in the job'svariables). - The just-copied jar is always the newest, so it is never deleted, and the
mtsa-latest-build.jarsymlink doesn't match themtsa-build.*.jarpattern, so it isn't touched. - Tagged releases in
/var/www/mtsa/download/releases/are not affected.
Note: the first master pipeline after this merges will delete every build except the 5 newest. Links to older timestamped builds will stop working.
Test plan
- YAML parses; the cleanup command was run against 14 dummy build files: it removed the oldest, kept the newest, and left the symlink working.
-
After merging, check the
copy-artifactjob log for "Removing ..." lines and confirm/var/www/mtsa/download/builds/holds 5 builds plusmtsa-latest-build.jar.