Question: post-build processing

Hi,

Is there any way to configure some post-build actions (say, ant build like "run after build" option in ipr build config) for particular build configuration or maybe globally for all builds?

Peter Ivanov.

0
26 comments

I'd do it as another build configuration for your particular project. You can set a "Dependency" on another build configuration, which triggers the build when the previous build finished successfully.

I have a Duplicate Code build configuration that runs whenever my primary build completes (and tests pass, etc).

0

Yes, we are using this feature, too. But what I'm interested in now is a way to run post-processing for every build, for example to perform some custom cleanup on its wokring svn base.

0

Peter,

You probably can achieve what you want by writing a plugin to TeamCity. If you can describe in more detail what kind of functionality you need we will provide some pointer into the API.

--
Best regards,

Yegor Yarko
Project Manager
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

Yegor,

The first thing we wanted to try is the folowing clean-up:
1. revert particular files in working copy.
2. find all non-versionned files using svn status
3. delete them.

It would be signifficantly faster than clean checkout in most of our cases.

0

BTW, if it is difficult to create a plugin like this, perhaps It would be easier to "override" the "clean checkout before build" option, so that it reverted the files in working base instead of svn co.

Edited by: Peter Ivanov on Apr 24, 2008 12:07 PM

0

Peter,

One of our developers (Pavel) has created a dummy sample of the agent plugin. Please find it attached.

It starts working when a build finishes and currently outputs a message to the agent log.

To deploy this plugin to your agents you should copy
buildCleanupPlugin.jar file to the /webapps/ROOT/update/plugins folder. Then all the agents will download it and install automatically. To compile the plugin you need to add all jar files from the ]]>/webapps/ROOT/update/buildAgent.zip!/lib folder.



Another simplistic approach to your task would be modifying the build scripts so that they perform all the necessary cleaning.

--
Best regards,

Yegor Yarko
Project Manager
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"



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

Thanks a lot!

I hope this information will be enough for us to make a plugin we need.
There is some difficulty in using the documentation, though. I found some javadoc in ]]>/devPackage/openApi-help, but found no docs on jetbrains.buildServer.agent there. I wonder if that is just a server-side part of docs, and the agent-side one can be found elsewhere. :) I'd be most thankful for any reference.

Petr.

p.s. and one more question. What TeamCity version is this plugin designed for?

Edited by: Peter Ivanov on Apr 29, 2008 12:52 PM

0

Teamcity version we are currently using is 3.0.1., and the plugin does not comply with jars that were fetched wollowing your instructions. I suppose, we have wrong version.

0

Have you considered upgrade to 3.1.1 version?

--
Pavel Sher

0

Well, we do consider it now :) When we will, can I expect that this plugin wiil fit?

0

Well it was designed and tested in 3.1.1, so it should work.

--
Pavel Sher

0

I'll mark my question answered, then. Thank you.

0

Yes, it fits with 3.1.1.
I'm currently scanning BuildAgent dirs for some trace of this dummy's work, because (apart from being extracted into plugins dir of all agents) it doesn't seem to produce any output. :) Must new plugin or some log appender be enabled explicitly?

0

You should not install this plugin manually on all of the agents, you need to place it into the TeamCity/webapps/ROOT/update/plugins folder, after that agents will download it and install automatically.

Plugin logs should appear in the teamcity-agent.log file on the agent. This plugin logs messages into the log on every build finish.

--
Pavel Sher

0

Naturally, that's exactly what I did. And still the teamcity-agent.log on agent looks like that:

>[2008-06-17 18:26:13,653] INFO - jetbrains.buildServer.AGENT - Publishing artifacts ...
>[2008-06-17 18:29:32,957] INFO - jetbrains.buildServer.AGENT - Done publishing artifacts teamcity-info.xml, total files published: 0
>[2008-06-17 18:29:32,957] INFO - jetbrains.buildServer.AGENT - Build finished: 25948
>[2008-06-17 18:29:35,222] INFO - jetbrains.buildServer.AGENT - Found runner simpleRunner for
>[2008-06-17 18:29:39,019] INFO - jetbrains.buildServer.AGENT - Getting sources...

Is there a way to check the list of plugins currently active on agent?

0

No, there is no way to see list of plugins, but you can check whether plugin was installed or not. Take a look at plugins folder on the agent, there should be jar and corresponding unpacked directory. If they exist check agent log4j configuration file: conf/teamcity-agent-log4j.xml. Try to enable debug level in this file and run build again.

--
Pavel Sher

0

The plugin is present on agent both it jar and unpacked, all elements of teamcity-agent-log4j.xml that contain "DEBUG" is uncommented, and still there is no plugin output.
What else can possibly be wrong? I'm out of ideas. :(

0

We've figured out what was wrong, the plugin archive was created incorrectly. I've attached new zip archive to this messsage (source code was not changed), please copy it to the TeamCity/webapps/ROOT/update/plugins folder and remove old jar file.

--
Pavel Sher



Attachment(s):
buildCleanupPlugin.zip
0

Ok, I'll try this one.
BTW, what was wrong? The content of new archive is quite misterious to me.

0

The archive had incorrect structure. Agent plugin should be a zip or jar archive with a root folder. In this root folder there should be "lib" directory with plugin jars. In this case all these jars will be loaded by agent.

--
Pavel Sher

0

Your archive seems to be broken, then. But it is easy to make one following your instructions.

0

I do not think it is broken, it works fine. It was created by jar tool, probably their format of ZIP archive is a bit different from a standard one.

--
Pavel Sher

0

BTW, what plugin deploy time is expected?
This zip contains the following path: buildCleanupPlugin.zip\buildCleanupPlugin\buildCleanupPlugin\lib\..., plus the deploy time of this plugin was signifficant. I stopped it actually. Is it expected?
My own hand-made plugin (buildCleanupPlugin.zip\buildCleanupPlugin\lib\...) is composed as desribed here and in docs, was deployed very quickly, but seems not to work :)

p.s: when I unpacked your zip, added .jar extention to the containing file (that was an achive, in fact) and deployed it, it worked. Is META-INF essential for pugin to work?

Edited by: Peter Ivanov on Jun 24, 2008 2:40 PM

0

Well right now I cannot tell you why it works when you rename it to .jar and does not if you leave .zip extension. It works fine with .zip extension on our side. What OS do you use on the agent?

Anyway META-INF is not required at the root level directory, it should not affect loading of the plugin. If your own hand made plugin still does not work feel free to send it to teamcity-feedback@jetbrains.com, we'll see where is the problem.

--
Pavel Sher

0

Pavel, I didn't rename .zip file. I repacked it, found another no-extention file inside, that was in fact another archive with proper structure inside. Then I added .jar extention to it, and that new archive worked well.

Sure, thanks. I will, if I need.

0

Indeed windows explorer shows some strange files inside the archive while other archivers (like 7-Zip) show correct structure. Probably explorer does not like zip archives created by jar tool. Anyway these files should not affect this plugin deployment. If you copied it to the TeamCity/ROOT/WEB-INF/update/plugins folder on the server and agents downloaded it it should be unpacked without these files.

--
Pavel Sher

0

Please sign in to leave a comment.