Skip to content

[Feature] Add Buildkite build agent #2956

@aidenhaak

Description

@aidenhaak

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 to true
  • GetCurrentBranch() would return the value that the BUILDKITE_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 🙂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions