Parameter to get VCS Trigger Commit Author

Hello!

I am configuring a Deployment Dashboard and would like to know if there is a parameter for grabbing the commit author for a build triggered by a VCS (git) commit.

I've looked through your documentation and could not find anything helpful. I did find the documentation (http://javadoc.jetbrains.net/teamcity/openapi/9.1/index-all.html#_G_  getCommiterIds) for how to obtain that information via API calls, but none of the values for the API worked.

I've tried a bunch of different combinations:

system.build.vcs.commitauthor

env.BUILD_VCS_COMMITAUTHOR

But nothing has worked so far.

Thanks in advance!

3 comments
Comment actions Permalink

Hello!

First of all, let me confirm if you are aiming to write a TeamCity plugin or a hosted dashboard pulling data from the TeamCity? 
For the latter, you may find REST API more suitable; for example, you may locate a build on interest:

[GET] /app/rest/builds/id:446

Out of retrieved data:

<build id="446" ...>
<lastChanges count="1">
<change id="442" version="8c20518e570d5693a80ce5f755c19034e5792c3a" username="fedor.rumyantsev" date="20200508T182531+0300" href="/app/rest/changes/id:442"/>
</lastChanges>
</build>

You may parse out both revision and username for all changes which were included into the build.
If this approach works for you, please find more details regarding our REST API here: https://www.jetbrains.com/help/teamcity/rest-api.html

If you are aiming to write a custom plugin instead, please let me know if you are looking for a parameter containing the commit author or a method allowing to retrieve this data, so I could suggest further.
0
Comment actions Permalink

This is actually for a parameter to be used in a build configuration. I'm not advanced enough to write my own plugin just yet. =o)

 

I'm looking for a parameter that would follow the same convention as:

 

system.x.x.commitauthor

build.x.x.commitauthor

0
Comment actions Permalink

Hello!

Thank you for the clarification. Unfortunately, there is no predefined parameter which would expose this data; we have two options which could be used to achieve the desired effect:
1) you may use REST API to access the changes of the current build (https://www.jetbrains.com/help/teamcity/rest-api.html#). For example, you could access the build ID property via teamcity.build.id build parameter and pass it into a custom script which would call this REST endpoint:
/app/rest/builds/id:<buildID>
By default this endpoint will return a summary on a build, including lastChanges section which will list the changes included into this build (and the username for the commit author too).

2) you can achieve the same via command line call of git.exe. You may access the commit hash by using the variable build.vcs.number.<VCSRootID> (for example, if I have a VCS Root StatusCheckGithub, my parameter would look like build.vcs.number.StatusCheckGithub. With this data, you can run git show <hash> and parse out commit author from that data after checkout:

$ git show 672f1cc8418f307136c75436455f3d6cd551f69c | grep Author
Author: Fedor Rumyantsev <address@mail.com>

In fact, given that the above parameter will yield the last change, you could achieve the same effect by just calling git show | grep Author (to get author of the last commit made in this branch).

I hope this helps; please do not hesitate to reach out if there are any details I could help with.


0

Please sign in to leave a comment.