Skip to content

Commit b2fe8e1

Browse files
authored
Add Semaphore 2.0 Support (#473)
This adds support for [Semaphore’s internal ENV vars](http://ttps://docs.semaphoreci.com/ci-cd-environment/environment-variables/) used for specifying the current git branch and git sha. To note: In the instance of a PR, the `SEMAPHORE_GIT_PR_BRANCH` variable has the expected branch name, whereas if code is being run against a branch directly (ie: `main`), `SEMAPHORE_GIT_BRANCH` is where it can be found. Given how the `findVar` code works - `SEMAPHORE_GIT_BRANCH` will function as a fallback for `SEMAPHORE_GIT_PR_BRANCH`.
1 parent 2edadbd commit b2fe8e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

env/git.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ func loadFromGit(gitArgs ...string) (string, error) {
156156
return strings.TrimSpace(string(out)), nil
157157
}
158158

159-
var gitBranchVars = []string{"GIT_BRANCH", "APPVEYOR_REPO_BRANCH", "BRANCH_NAME", "BUILDKITE_BRANCH", "CIRCLE_BRANCH", "CI_BRANCH", "CI_BUILD_REF_NAME", "DRONE_BRANCH", "HEROKU_TEST_RUN_BRANCH", "TRAVIS_PULL_REQUEST_BRANCH", "TRAVIS_BRANCH", "WERCKER_GIT_BRANCH", "CI_COMMIT_REF_NAME", "BITRISE_GIT_BRANCH"}
159+
var gitBranchVars = []string{"GIT_BRANCH", "APPVEYOR_REPO_BRANCH", "BRANCH_NAME", "BUILDKITE_BRANCH", "CIRCLE_BRANCH", "CI_BRANCH", "CI_BUILD_REF_NAME", "DRONE_BRANCH", "HEROKU_TEST_RUN_BRANCH", "TRAVIS_PULL_REQUEST_BRANCH", "TRAVIS_BRANCH", "WERCKER_GIT_BRANCH", "CI_COMMIT_REF_NAME", "BITRISE_GIT_BRANCH", "SEMAPHORE_GIT_PR_BRANCH", "SEMAPHORE_GIT_BRANCH"}
160160

161-
var gitCommitShaVars = []string{"GIT_COMMIT_SHA", "APPVEYOR_REPO_COMMIT", "BUILDKITE_COMMIT", "CIRCLE_SHA1", "CI_BUILD_REF", "CI_BUILD_SHA", "CI_COMMIT", "CI_COMMIT_ID", "DRONE_COMMIT", "GIT_COMMIT", "HEROKU_TEST_RUN_COMMIT_VERSION", "WERCKER_GIT_COMMIT", "TRAVIS_PULL_REQUEST_SHA", "TRAVIS_COMMIT", "CI_COMMIT_SHA", "BITRISE_GIT_COMMIT"}
161+
var gitCommitShaVars = []string{"GIT_COMMIT_SHA", "APPVEYOR_REPO_COMMIT", "BUILDKITE_COMMIT", "CIRCLE_SHA1", "CI_BUILD_REF", "CI_BUILD_SHA", "CI_COMMIT", "CI_COMMIT_ID", "DRONE_COMMIT", "GIT_COMMIT", "HEROKU_TEST_RUN_COMMIT_VERSION", "WERCKER_GIT_COMMIT", "TRAVIS_PULL_REQUEST_SHA", "TRAVIS_COMMIT", "CI_COMMIT_SHA", "BITRISE_GIT_COMMIT", "SEMAPHORE_GIT_SHA"}
162162

163163
var gitCommittedAtVars = []string{"GIT_COMMITTED_AT", "GIT_COMMITED_AT", "CI_COMMITTED_AT", "CI_COMMITED_AT", "CI_TIMESTAMP"}
164164

0 commit comments

Comments
 (0)