Maven snapshot dependency trigger: detailed

Hello guys, i've been trying to setup up a very simple project with maven snapshot dependency trigger and come across some very stupid problems :) So here is the story:

  • Maven projects
    • Parent pom with common settings
    • Some gwt component
    • Some webapp that includes gwt component
  • I have a Nexus maven repository with following setup:
    • my.app.snapshots - my hosted repo for my snapshots
    • Several proxy repos - for proxying cental and other repos
    • my.app.group - repo group that unites all these repos
  • Maven pom's:
    • Parent pom contains a my.app.snapshots repo in distribution management section
    • Parent pom doesn't contain repositories section. Instead settings.xml holds mirrorOf=* record using my.app.group as a target
    • gwt and webapp components doesn't have distribution management or repositories sections (just inherit these from parent)
  • Teamcity configs:
    • 3 configs - one for each component. Each has a maven snapshot dependency build trigger.
  • When gwt component is actually redeployed to Nexus - build for webapp is not started.


Somehow after some experiment i've found that if repositories section is listed in each pom explicitly - trigger works fine. However if repositories section is only added to parent pom - it doesn't work. More strange - if repositories section is added to parent pom and webapp, but not added to gwt component - it still doesn't work (well in fact i'm not sure that i haven't missed something in this case).

So questions are:

  1. What repository exactly do Teamcity watch to determine if snapshot dependencies have been updated? All repos in the repositories section in pom? Repo in the distribution management section? What about release/snapshot flags in pom for these repos?
  2. What if repos listed in pom are overriden by the settings.xml mirrorOf?
  3. Should repositories section be inherited correctly from parent pom or it must always be specified explicitly?
  4. Dependency on parent pom artefact is not considered an ordinary snapshot dependency in this case? No build triggering?
4 comments

Hello, Dmitry

Here are the answers

1. If not defined explicitly in the trigger configuration TeamCity uses the same repository list that is used by Maven itself for resolving artifacts. It could be defined in the project pom, one of it's parent pom, or in the settings.xml (http://confluence.jetbrains.net/display/TCD5/Maven+Support).
The distribution management section doesn't participate in artifact resolution. It's used only for deployment.

2. All the definitions in the settings.xml including mirrors are applicable for the Maven artifact trigger.

3. All repository definitions in the parent POM must be taken. If they aren't this is a bug. Please send me your POMs for investigation.

4. See the previous answer. Normally TeamCity should resolve artifacts in absolutely the same manner as Maven (2.2.1) does it. If it doesn't it's a bug.


Probably the reason is that TeamCity doesn't see your settings.xml. Where is it located?

0

Thanks, Sergey!

I've double checked my test case and found that Teamcity trigger actually works sometimes. The problem now is that behaviour looks non-deterministic.

So i do redeploy snapshot artifact, but the build is not triggered (at least no within 10 minutes). But when i modify build configuration, for example, add another trigger (i used maven artifact trigger for non-existing artifact), the build is triggered by snapshot trigger once. But - only once.

Also if a change settings.xml (both ~/.m2/settings.xml and buildAgent/plugins/maven/conf/settings.xml) the build is triggered once.

So next couple of questions:

1. How often does Teamcity check if snapshot was updated in the repository?
2. Is there any quite period?
3. Is there a way to enable debug mode for Teamcity and see if it really checks the artifact state?

0

Dmitry,

I guess if you simply redeploy an artifact built upon the same sources trigger won't react because the artifact content hasn't changed. The trigger compares artifact checksums. When testing the trigger you should ensure you've made real changes to the artifact before each redeploy.

By default TeamCity compares artifact checksums each 10 minutes without any quiet period (it's going to be implemented in 6.0).
You can change the default behavior by setting the following system properties

teamcity.maven.artifactTrigger.checkInterval (default = 600 [sec]) - the interval of remote repository polling
teamcity.maven.artifactTrigger.timeToCache (default = 600 [sec]) - time for which a remote artifact digest is kept in the cache

The cache is used to share results of repository requests between many triggers if they watch the same artifact. You can switch it off by setting the second property to 0.

To enable trigger logging please add the following definition to <TC inst dir>/conf/teamcity-server-log4j.xml

  <category name="jetbrains.buildServer.maven">
    <priority value="DEBUG"/>
    <appender-ref ref="ROLL"/>
  </category>

Please send me the log if it's not explanatory enough.

Thank you.

0

I've set properties to 10 seconds and that gave me expected behavior. Wll, at least - behaviour expected by me :)

Thanks!

0

Please sign in to leave a comment.