Skip to content

Commit b9e81d3

Browse files
committed
Open build in browser with --browse
1 parent 09aac67 commit b9e81d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

git-buildkite

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ if [ -z "$BUILDKITE_ORGANIZATION" -o -z "$BUILDKITE_PIPELINE" ]; then
175175
exit 1
176176
fi
177177

178+
# Parse flags before parsing arguments
179+
let i=1
180+
while [[ $i -le $# ]]; do
181+
case "${!i}" in
182+
"--browse")
183+
browse=yes
184+
shift $i
185+
esac
186+
let i=i+1
187+
done
188+
178189
if [[ "$#" -eq 0 ]]; then
179190
if ! current_branch_exists; then
180191
echo "Woops, you don't seem to be on a branch." >&2
@@ -359,3 +370,13 @@ echo
359370
echo " ${build_url}"
360371
echo
361372

373+
# Open a browser if we can
374+
if [[ -n "$browse" ]]; then
375+
if which open >/dev/null 2>&1; then
376+
open "${build_url}"
377+
elif which xdg-open >/dev/null 2>&1; then
378+
xdg-open "${build_url}"
379+
else
380+
echo "Sorry but I don't know how to open your browser! Copy and paste the link above as you like."
381+
fi
382+
fi

0 commit comments

Comments
 (0)