How can I access the value of the build comment from within the build?

When the user launches a build manually they have the option to key in a "build comment".  Can I get access to this comment from within my build?  

I was hoping to see some sort of %build.Comment% variable listed in the properties chooser dialog, but unfortunately it is not there.  That would be my preferred solution.  But if that is not possible, is this information available via the REST api?

8 comments

Build's comment is availalbe via REST when you request a build.

BTW, if you need to pass some value into the build it seems more appropriate to add/modify a system property in run custom build dialog. And the property can be easy available in the build.

0

Thanks.

What I am doing is I have a special build config just for copying artifacts to a UNC share for our QA folks to pick up.  I also want to update a Sharepoint page with the build number and the comment.  

0

Thank you for the details. I see the point.

I am not sure it's a good idea to add a property with a comment to every build. Luckily enough, you can write a very simple TeamCity plugin to do the task.
If you choose to go this route, you can grab GroovyPlug and get the feature with a single line in GroovyPropertiesProvider.groovy.

The line could look like:

public Map<String, String> getParameters(@NotNull final SBuild build, final boolean emulationMode) {
     ...
     if (build.getBuildComment() != null) parameters.addEnvAndSystem("build.comment", build.getBuildComment().getComment());

     ...
}


Message was edited by: Yegor Yarko

0

Could you give me a hint how  can I get the comment to the currently running build?

I try this way: http://myteamcity/httpAuth/app/rest/builds/?locator=running:true,buildTypeId:bt3 and it shows me details of currently running build that I am interested in but I do not see any comment.

What I want to do is to send email that will contain a comment after the build finishes.
Could you help me with this?
thanks,
Łukasz

0

Hi

Do you need VCS commit messages or build comments within TeamCity?

0

I'd use URL like
http://myteamcity/httpAuth/app/rest/builds/id:<internal_build_id>/
where you can get <internal_build_id> from teamcity.build.id configuration paramter.

The response shoul dhave "comment" element.

> What I want to do is to send email that will contain a comment after the build finishes.
If this email is ment for users of TeamCity, you can consider customizing notificaiton template to include whatever information you need.

0

Please sign in to leave a comment.