Skip to content

Instantly share code, notes, and snippets.

@akshaymankar
Last active August 10, 2017 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akshaymankar/72e0264e74c8916a778223ac8c27ac31 to your computer and use it in GitHub Desktop.
Save akshaymankar/72e0264e74c8916a778223ac8c27ac31 to your computer and use it in GitHub Desktop.
HIjack a concourse container by URL
#!/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 "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment