diff --git a/hooks/pre-checkout b/hooks/pre-checkout index 064e8d5..87cd95e 100755 --- a/hooks/pre-checkout +++ b/hooks/pre-checkout @@ -12,6 +12,10 @@ if [[ -n "${BUILDKITE_PLUGIN_GOLANG_IMPORT:-}" ]]; then # Now checkout into the correct import location within that gopath export BUILDKITE_BUILD_CHECKOUT_PATH="$GOPATH/src/$BUILDKITE_PLUGIN_GOLANG_IMPORT" echo "BUILDKITE_BUILD_CHECKOUT_PATH=$BUILDKITE_BUILD_CHECKOUT_PATH" + + # Add golang bin commands to path + export PATH="$PATH:$GOPATH/bin" + echo PATH="$PATH" else echo "+++ :golang: No 'import' option specified" exit 1 diff --git a/tests/pre-checkout.bats b/tests/pre-checkout.bats index f98d74b..d65ff07 100644 --- a/tests/pre-checkout.bats +++ b/tests/pre-checkout.bats @@ -18,4 +18,13 @@ export BUILDKITE_PIPELINE_SLUG="my-pipeline" assert_success assert_output --partial "BUILDKITE_BUILD_CHECKOUT_PATH=/builds/.golang/my-pipeline/src/my-dir" +} + +@test "adds GOPATH/bin to PATH" { + export PATH=/bin + + run $PWD/hooks/pre-checkout + + assert_success + assert_output --partial "PATH=/bin:/builds/.golang/my-pipeline/bin" } \ No newline at end of file