Skip to content

Commit

Permalink
Merge pull request #5 from buildkite-plugins/add-gopath-bin-to-path
Browse files Browse the repository at this point in the history
Add $GOPATH/bin to $PATH
  • Loading branch information
toolmantim authored May 3, 2018
2 parents 55f49fc + 02e95b2 commit e60716e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hooks/pre-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/pre-checkout.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit e60716e

Please sign in to comment.