Last active
August 10, 2017 16:26
-
-
Save akshaymankar/72e0264e74c8916a778223ac8c27ac31 to your computer and use it in GitHub Desktop.
Revisions
-
akshaymankar revised this gist
Aug 10, 2017 . No changes.There are no files selected for viewing
-
akshaymankar created this gist
Aug 10, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/bin/bash set -eu print_usage() { echo "Usage: $(basename "$0") <job-url>" } invalid_job_url() { echo "Argument [\"$1\"] isn't a valid job url." } main() { if [ $# -ne 1 ]; then print_usage exit 1 fi if [[ "$1" =~ (https://[^\/]*)/teams/.*/pipelines/(.*)/jobs/([^\/]*)(\/.*|$) ]]; then target_url=${BASH_REMATCH[1]} target=$(fly targets |grep "${target_url}" | awk '{print $1}') if [ -z "$target" ]; then invalid_job_url "$1" exit 1 fi job_name="${BASH_REMATCH[3]}" pipeline_name="${BASH_REMATCH[2]}" fly -t "${target}" hijack -j "${pipeline_name}/${job_name}" else invalid_job_url "$1" exit 1 fi } main "$@"