From 16b071fa1a18ad57bdb67c1a0c003e4eb5b966c5 Mon Sep 17 00:00:00 2001 From: Carolina Lopez Date: Tue, 7 Jun 2022 12:25:26 -0500 Subject: [PATCH 1/3] Allow github_enterprise as a valid provider --- hooks/pre-command | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/pre-command b/hooks/pre-command index 885dcd4..7201ed3 100755 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -1,8 +1,8 @@ #!/bin/bash set -euo pipefail -if [[ "${BUILDKITE_PIPELINE_PROVIDER:-}" != "github" ]] ; then - echo "⛔️ this plugin can only be used on piplines associated with github repositories" >&2 +if [ "${BUILDKITE_PIPELINE_PROVIDER:-}" != "github" ] && [ "${BUILDKITE_PIPELINE_PROVIDER:-}" != "github_enterprise" ] ; then + echo "⛔️ this plugin can only be used on pipelines associated with github repositories" >&2 exit 1 fi From 5c5c58b4a31e39775f7a6565d9252c6d32b4bc79 Mon Sep 17 00:00:00 2001 From: Carolina Lopez Date: Tue, 7 Jun 2022 12:36:01 -0500 Subject: [PATCH 2/3] Get repoFq for github_enterprise repo variable --- hooks/pre-command | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hooks/pre-command b/hooks/pre-command index 7201ed3..984f161 100755 --- a/hooks/pre-command +++ b/hooks/pre-command @@ -12,8 +12,15 @@ if [[ "${BUILDKITE_PULL_REQUEST:-false}" == "false" ]] ; then fi pullReqNo="${BUILDKITE_PULL_REQUEST}" +regexRepo="" +if [ "${BUILDKITE_PIPELINE_PROVIDER:-}" = "github" ] ; then + regexRepo="github.com[:/](.*).git[/]?" +elif [ "${BUILDKITE_PIPELINE_PROVIDER:-}" = "github_enterprise" ]; then + regexRepo="git@${BUILDKITE_REPO_SSH_HOST:-}[:/](.*).git[/]?" +fi + repoFq="" -if [[ "${BUILDKITE_REPO:-}" =~ github.com[:/](.*).git[/]? ]]; then +if [[ "${BUILDKITE_REPO:-}" =~ $regexRepo ]]; then repoFq="${BASH_REMATCH[1]}" else echo "⛔️ the BUILDKITE_REPO variable has an unexpected format" >&2 From b28b9d5d68a99065df2dd2ce75b89376ddbb2339 Mon Sep 17 00:00:00 2001 From: Carolina Lopez Date: Tue, 7 Jun 2022 12:39:53 -0500 Subject: [PATCH 3/3] Fix typo --- tests/pre-command.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pre-command.bats b/tests/pre-command.bats index c67bd3b..c2fabee 100644 --- a/tests/pre-command.bats +++ b/tests/pre-command.bats @@ -8,7 +8,7 @@ load '/usr/local/lib/bats/load.bash' run "$PWD/hooks/pre-command" assert_failure - assert_output --partial "this plugin can only be used on piplines associated with" + assert_output --partial "this plugin can only be used on pipelines associated with" } @test "ensure early exit if not a PR-build" {