Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store build logs in subdirectories per branch and per month
Note this update requires an additional msys package to be installed (rsync2) so you may have to re-run setup-mingw64.ps1 once before starting buildserver/build_package.ps1.
- Loading branch information
Showing
3 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! /bin/bash | ||
# | ||
# A function to upload build logs | ||
# If a branch is known it will upload to | ||
# build-logs/branch/yyyy-mm/logfile | ||
# otherwise it will upload to | ||
# build-logs/logfile | ||
|
||
log_file=$1 | ||
host=$2 | ||
log_dir=$3 | ||
remote_branch_dir=$4 | ||
base_dir=$(pwd) # A dummy base directory used in rsync | ||
|
||
# This function will create a remote directory | ||
# It will only run if $host is configured. | ||
# Note it assumes the parent directory exists and it won't | ||
# create intermediate subdirectories if that is not the case | ||
function create_remote_dir() | ||
{ | ||
if [[ -n "$host" ]] | ||
then | ||
# For this hack $base_dir is just an arbitrary existing directory | ||
# It doesn't matter which one | ||
# No files will be copied from it anyway because of the exclude parameter | ||
rsync -a --exclude='*' "$base_dir"/ "$1" | ||
fi | ||
} | ||
|
||
if [[ -n "$host" ]] | ||
then | ||
echo "Uploading log file '$(basename $log_file)'" | ||
create_remote_dir "$host"/build-logs | ||
if [[ -z "$remote_branch_dir" ]] | ||
then | ||
# We don't know the build type yet, so we can't determine | ||
# the final remote directory to store it | ||
# So let's just store it in the top-level so we have a trace | ||
# of the build start or very early failures | ||
rsync -a "$log_file" "$host"/build-logs | ||
else | ||
# Now the subdirectory to store the log file is is known | ||
# In addition group per month to simplify navigation even more | ||
month_part=$(date +%Y-%m) | ||
|
||
create_remote_dir "$host"/build-logs/$remote_branch_dir | ||
create_remote_dir "$host"/build-logs/$remote_branch_dir/$month_part | ||
|
||
rsync -a "$log_file" "$host"/build-logs/$remote_branch_dir/$month_part | ||
|
||
# Finally remove the initially start build log uploaded earlier | ||
# Disable fatal error handling though to prevent the complete script from exiting | ||
# if no early build log exists | ||
echo "Removing initial startup build log uploaded earlier" | ||
set +ex | ||
rsync -rv --delete --include="$(basename $log_file)" --exclude='*' "$base_dir"/ "$host"/build-logs/ | ||
set -ex | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters