Skip to content

Instantly share code, notes, and snippets.

@kazazes
Last active December 12, 2018 20:10
Show Gist options
  • Save kazazes/576909ef64b49884dacd4c11c38075c2 to your computer and use it in GitHub Desktop.
Save kazazes/576909ef64b49884dacd4c11c38075c2 to your computer and use it in GitHub Desktop.
Tired of waiting for your GC console to load while you spam-commit to a new repo? Sick of copy pasting build UUIDs from your terminal? Commit, run this puppy, and relax while tmux keeps you appraised of your menial progress. Tested with 20 simultaneous builds.
#!/bin/sh
set -e
echo "Checking for running Google Cloud Build jobs..."
BUILDS=$(gcloud builds list | grep WORKING | cut -f1 -d " " | tr "\n" " " | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' )
[[ -z "$BUILDS" ]] && echo "No running builds." && exit 1
tmux start-server
tmux -f /dev/null new-session -c $PWD -d -s "GC Build"
for build in $BUILDS
do
TITLE=$(gcloud builds describe $build | head -n 3 | tail -n 1)
tmux new-window -a -c $PWD -n "$TITLE" "gcloud builds log --stream $build"
tmux setw status-position top
tmux setw mouse on
tmux setw status on
tmux setw status-justify centre
tmux setw monitor-silence 15
tmux setw remain-on-exit on
done
tmux select-window -t "GC Build":1
tmux -2 attach-session -t "GC Build"
@kazazes
Copy link
Author

kazazes commented Dec 12, 2018

I've needed this for so long...

google cloud build stream logs all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment