Open garex opened 8 years ago
I wrote a short Python tool to do this, if anyone is interested: https://gist.github.com/nolanlawson/7b7961b49b75e406dc7090ce6217bb5f
"One liner";) for travis whatsup
travis whatsup \
| grep --extended-regexp '(failed|errored)' \
| cut -f1 -f3 -d' ' \
| tr -d '#' \
| xargs -n 2 \
bash -c 'travis show -r $1 $2 \
| grep --extended-regexp --only-matching "[0-9\.]+ (failed|errored)" \
| cut -f1 -d" " \
| xargs -n 1 travis restart -i -r $1 \
| while read line; do echo "$1: $line"; done' \
bash
$ travis whatsup | grep --extended-regexp '(failed|errored)' | cut -f1 -f3 -d' ' | tr -d '#' | xargs -n 2 bash -c 'travis show -r $1 $2 | grep --extended-regexp --only-matching "[0-9\.]+ (failed|errored)" | cut -f1 -d" " | xargs -n 1 travis restart -i -r $1 | while read line; do echo "$1: $line"; done' bash
arvenil/some-repo: job #1.1 has been restarted
arvenil/some-repo: job #1.2 has been restarted
arvenil/some-repo: job #1.3 has been restarted
arvenil/some-repo: job #1.4 has been restarted
arvenil/some-repo: job #1.5 has been restarted
org/repo: job #13.1 has been restarted
org/repo: job #13.2 has been restarted
org/repo: job #13.3 has been restarted
Sometimes you have builds with something unstable inside (casper/phantom). It gives you often failed jobs inside build. You can restart build. But if you have too many jobs inside it will be a waste of time.
So how to restart only failed jobs? Good old bash to the rescue.
travis show | grep --extended-regexp --only-matching '[0-9\.]+ (failed|errored)' | awk '{print $1}' | xargs --max-args=1 --no-run-if-empty travis restart