If you use Buildkite then you will have to use GitVersion from the command line as there is currently no GitVersion Buildkite plugin.


By default Buildkite calls git fetch with the flags -v --prune which can cause issues on new build agents since branches or tags might not be available locally on the build agent when GitVersion runs. This can be fixed by altering the Buildkite agent configuration either by:

  • Setting the environment variable BUILDKITE_GIT_FETCH_FLAGS to -v --tags
  • Setting configuration value git-fetch-flags to -v --tags in your agent configuration file

If you are running GitVersion in a docker container make sure to propagate the BUILDKITE, BUILDKITE_BRANCH, and BUILDKITE_PULL_REQUEST environment variables (c.f. example below).


There are many ways to run GitVersion in a Buildkite pipeline. One way using the GitVersion docker image and using build meta-data to share version info between build steps. Such a pipeline might look like the following:


  - label: "Calculate version"
    command: buildkite-agent meta-data set "GitVersion_SemVer" $(./dotnet-gitversion -showvariable SemVer)
      - docker#v3.9.0:
        image: "gittools/gitversion"
          - "BUILDKITE"
          - "BUILDKITE_BRANCH"

  - wait

  - label: "Use calculated version"
    command: echo "Calculated version is $(buildkite-agent meta-data get "GitVersion_SemVer")"

Another way could be via the Buildkite hooks. Adding the following line to the .buildkite/hooks/post-checkout file:

eval $(gitversion | jq -r 'to_entries[] | "buildkite-agent meta-data set GitVersion_\(.key) \(.value)"')

Assuming your Buildkite agent has dotnet and gitversion installed and on the path, all the calculated GitVersion variables will have a corresponding meta-data key set.