Using the TeamCity change set in Ant?

Our team has a time-consuming Ant task that only needs to run if files were changed in a certain package. We'd like to be able to scan the change set and set an Ant property that would indicate whether or not to run the time-consuming task.

How can we accomplish this with TC/Ant?

thx

7 comments
Comment actions Permalink

This is only possible in TeamCity 4.x with help of system property teamcity.build.changedFiles.file which points to a file containing changed files information. In TC 3.x this can be done via plugin only.

--
Pavel Sher

0
Comment actions Permalink

Can you expand on the plugin solution? We are using checkout on server, I assume we would have to create a server plugin which inspects the changeset file then sets a property for the antRunner on the agent can pick up? Please confirm this is a valid approach.

0
Comment actions Permalink

On server there is special extension point jetbrains.buildServer.serverSide.ParametersPreprocessor which accepts SRunningBuild and allows you to modify build parameters passed to an agent. Build parameters having prefix system. are transformed to system properties.

You should implement interface jetbrains.buildServer.serverSide.ParametersPreprocessor and register your implementation in ServerExtensionHolder:
extensionHolder.registerExtension(ParametersPreprocessor.class, "changedFilesProvider", ]]>);

Changes can be obtained from the SRunningBuild:
SRunningBuild.getContainingChanges()

From the change you can obtain information about affected files. So your params preprocessor should convert this information to some text format and add it as build parameter with name starting with system. prefix.

--
Pavel Sher

0
Comment actions Permalink

Sorry maybe I'm missing something but SRunningBuild.getContainingChanges() appears to return a list of type jetbrains.buildServer.vcs.SVcsModification which does not seem to get me to a list of actual files changed?

0
Comment actions Permalink

See VcsModification.getChanges() method.

--
Pavel Sher

0
Comment actions Permalink

I'm running TeamCity Professional Version 3.0.1 (build 6010) just want to confirm what you describe will work in this version?

0
Comment actions Permalink

I think this should work, as far as I remember all these methods were in 3.0.1 too.

--
Pavel Sher

0

Please sign in to leave a comment.