Team City has all the build related information in certain configuration parameters, but in order to make them available to greenkeeper-lockfile, they need to be manually mapped to environment variables in the build configuration.
This PR assumes that these two variables are available to the script:
VCS_ROOT_URL which is mapped to the vcsroot.<vcsrootid>.url parameter
VCS_ROOT_BRANCH which is mapped to the teamcity.build.branch parameter
The GH_TOKEN environment variable also needs to be defined, but that needs to happen independently of the CI server.
In order to detect if builds are coming from a PR or not, we can check the name of the branch. If it ends with /merge or /head, it means it is a pull request according to this post.
In order to set the firstPush and correctBuild flags correctly I copied the logic from the Codeship implementation. Unlike Codeship, Team City does not provide any parameter to access the commit message, so I added a function in gitHelpers to do that.
Edit: I just realized that https://github.com/greenkeeperio/greenkeeper-lockfile/pull/106 is also trying to add support to Team City. I hadn't seen it until I created the PR. There are some differences between both PRs. I'm happy to close this PR if the other path is preferred. Sorry for the noise.
This PR adds support for Team City.
Team City has all the build related information in certain configuration parameters, but in order to make them available to
greenkeeper-lockfile
, they need to be manually mapped to environment variables in the build configuration.This PR assumes that these two variables are available to the script:
VCS_ROOT_URL
which is mapped to thevcsroot.<vcsrootid>.url
parameterVCS_ROOT_BRANCH
which is mapped to theteamcity.build.branch
parameterThe
GH_TOKEN
environment variable also needs to be defined, but that needs to happen independently of the CI server.In order to detect if builds are coming from a PR or not, we can check the name of the branch. If it ends with
/merge
or/head
, it means it is a pull request according to this post.In order to set the
firstPush
andcorrectBuild
flags correctly I copied the logic from the Codeship implementation. Unlike Codeship, Team City does not provide any parameter to access the commit message, so I added a function ingitHelpers
to do that.Edit: I just realized that https://github.com/greenkeeperio/greenkeeper-lockfile/pull/106 is also trying to add support to Team City. I hadn't seen it until I created the PR. There are some differences between both PRs. I'm happy to close this PR if the other path is preferred. Sorry for the noise.