cloudnative / teamcity-webhooks

A TeamCity plugin that sends the results of a build to a webhook URL
Apache License 2.0
9 stars 10 forks source link

Branch posted is always master branch #5

Open joelwkall opened 8 years ago

joelwkall commented 8 years ago

I have a git repository at bitbucket with multiple branches. These are build in TeamCity in a build project that has multiple branches. When a branch is built I expect the WebHooks to POST to my endpoint and notify which branch was built. However, it seems as if the "scm" data in the JSON is always the same, regardless of which branch was built. Example:

"scm": {
      "url": "https://bitbucket.org/xxx/yyy.git",
      "branch": "origin/master",
      "commit": "zzzz"
    }

Even though the branch build was actually not origin/master.

Can I configure the plugin to use the correct branch name in the POST?

joelwkall commented 8 years ago

Just looked in the code and found these lines:

if (! vcsRoots.isEmpty()) {
      val vcsRoot = vcsRoots.get(0).getVcsRoot();
      scm = Scm.builder().url(vcsRoot.getProperty("url")).
                          branch(vcsRoot.getProperty("branch").replace("refs/heads/", "origin/")).
                          commit(vcsRoot.getCurrentRevision().getVersion()).build();
    }

It looks like it is only looking at the vscRoot of the build project, not the branch of the actual build. How hard would it be to make it look at the build branch instead?