Created
January 20, 2020 15:14
-
-
Save nevstokes/5bdba506f5e8e265166588ee02f1c3fa to your computer and use it in GitHub Desktop.
Processes a Bamboo build log and extracts timings for each task
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
#!/usr/bin/env bash | |
if [[ "$#" -ne 1 ]]; then | |
echo "Usage: $0 LOGFILE" >&2 | |
exit 1 | |
fi | |
LOGFILE=$1 | |
if ! [[ -f "${LOGFILE}" ]]; then | |
echo "${LOGFILE} not found" >&2 | |
exit 1 | |
fi | |
while IFS=$'\t' read START TASK ; do | |
END=$(grep "Finished task '${TASK}'" ${LOGFILE} | awk -F$'\t' '{ print $2; }') | |
DURATION=$(expr $(date +%s -d "${END}") - $(date +%s -d "${START}")) | |
printf "\033[32m%-36s\033[0m%3s seconds\n" "${TASK}" "${DURATION}" | |
done < <(grep -E "Starting task '.+?'" ${LOGFILE} | sed -E "s/.+?\t(.+?)\tStarting task '([^']+?)'.+$/\1\t\2/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment