-
Notifications
You must be signed in to change notification settings - Fork 658
Description
GitVersion should be able to use Buildkite environment variables to detect the current branch rather than doing some extra checkouts to get out of a detached HEAD state.
Detailed Description
Add a new Buildkite class that extends the BuildAgentBase
class. This would allow GitVersion to work more seamlessly when running on a Buildkite agent. Implementation would roughly be:
CanApplyToCurrentContext()
would check that the$BUILDKITE
environment variable is set totrue
GetCurrentBranch()
would return the value that theBUILDKITE_BRANCH
environment variable is set to
c.f. Buildkite Environment Variables
Could also be nice to have GitVersion set version info via Buildkite's meta-data - but I'm not sure how good of an idea it is to have GitVersion exec another process...Besides you can always just call it yourself somewhere in your build pipeline like so:
buildkite-agent meta-data set "GitVersion_SemVer" $(gitversion -showvariable SemVer)
Context
By default a Buildkite agent checks out a branch in detached HEAD state. It's possible to work around it via doing this at start of every build:
git checkout $BUILDKITE_BRANCH
git reset HEAD --hard $BUILDKITE_COMMIT
Would be nice for GitVersion to automatically detect the branch name via the built-in $BUILDKITE_BRANCH
environment variable.
Possible Implementation
Have a branch ready to PR here: aidenhaak@f9492d6 🙂