Getting the build ID and revision of last successful build

I'd like to get the build ID and revision number of the last successful build. I know that I can use http:///repository/download/]]>/latest.lastSuccessful/teamcity-ivy.xml which contains the build revision. I'm trying to figure out a way to cross-reference the artifact directory on the server -- and the artifacts are stored in a directory with the build ID rather than the revision number.

9 comments

Hello,

The only way to do it now is to write your own plugin. If you need assistance feel free to contact us.

--
Pavel Sher

0

I guess I'm out of luck at the moment then... I don't know java.

0

Hello,

I've attached a plugin that can return build id for the last successful
build of the specified build configuration. The plugin is accessible by HTTP
without authentication. Use the following url to access the plugin:
http:///buildId.html?buildTypeId= To install plugin simply copy buildDetailsPlugin.jar to the TeamCity/WEB-INF/lib folder and restart server. -- Pavel Sher Software Developer JetBrains, Inc. http://www.jetbrains.com "Develop with pleasure!" "Brian Baker" wrote in message news:14528903.7931206645883862.JavaMail.jive@app4.labs.intellij.net... >]]>I guess I'm out of luck at the moment then... I don't know java.








Attachment(s):
buildDetailsPlugin.jar
buildDetailsPlugin-src.jar
0

Awesome! Thanks for taking the time to put it together.

0

Hi Pavel

The plugin you attached only appears to return the build id of a build. Like Brian, I'm after the build revision number (in my case, corresponding to a single Subversion VCS root) as well. How do we retrieve this information? It looks like the TeamCity system property %system.build.vcs.number.N% is what I'm looking for. But I'd like to be able to retrieve this information for any past build via TeamCity's Java API, not in Ant for a current build.

I've perused the source code for TeamCity server-side extensions. I tried printing out several property values of the first BuildRevision in the list returned by build.getRevisions(). The closest property seems to be revision.getRevisionDisplayName(). But I've noticed this returns the revision number for the entire Subversion repository at the time when the build was commenced. I want the revision number for the VCS root configured for the build, which is a specific branch in the repository.

Any ideas would be much appreciated.

Thanks
Rhys

0

Actually %system.build.vcs.number.N% contains the same revision which will be returned by BuildRevision.getRevision() method. The method SBuild.getRevisions() returns collection of BuildRevision instances (one instance per VCS root), the BuildRevision object itself contains VCS root and if you need to obtain revision of the concrete VCS root you need to search for a corresponding BuildRevision in the returned list.

For subversion all of these revisions are always revisions of repository itself. We have a request to associate with build revisions of last detected change instead, if you need this functionality please watch/vote for this issue: http://jetbrains.net/tracker/issue/TW-4527

--
Pavel Sher

0

Thanks for your prompt reply. Looks like my only option at this stage is to use a Subversion Java API (e.g. SVNKit) in my TeamCity plug-in to connect to the repository directly. Not so nice, but no worries.

0

Bumping this thread to see if there's a better way to do this in the 5.0 version of TeamCity. I've installed this plugin, but when I attempt to configure the %system.build.vcs.number.N% property I get an indication that the agent isn't compatible, which I presume means that the plugin isn't recognized?

Any other suggestions on how to get the last successfully  built revision from an MSBuild script? I'm tempted to simply write it to a file and track it outside of TeamCity.

0

Tim,

%system.build.vcs.number.N% (where N is the number of the VCS root attached) is a standard property that is available by default. Please check you use it right.

Since TeamCity 5.0 there is a basic REST API available.

If you need to get last successful build information from outside of TeamCity you can use request like http://<teamcity_server_url>/app/rest/buildTypes/id:<internal build configuration id>/builds/status:SUCCESS
and parse the resulting XML extracting "revisions" element.

0

Please sign in to leave a comment.