Friday, October 5, 2018

Teamcity: Maven Artifact Dependency Trigger - an example

I'm back to blogging after a year break. This blog is about the Teamcity "Maven Triggers". I didn't find a good example usage of this build trigger and hence this blog.

Teamcity by default provides many build trigger options and the most used could be "VCS Trigger" or "Finish Build Trigger" or "Schedule Trigger". But I want to focus on the less used "Maven Triggers"

This Maven trigger will monitor a maven repository for the configured GAV (GroupID:ArtifactID:version) co-ordinates and if it notices any new version published, it will trigger  a build. We wanted to use this feature to avoid configuring branch based jobs (build-configs).

Teamcity provides two variants of this "Maven Trigger"

  1. Maven Snapshot Dependencies Trigger
  2. Maven Artifact Dependency Trigger

This blog explains the usage of second variant.

How it works?
We have a build which publishes it's artifact to Nexus maven repo as shown below



In this case, some "source" build is publishing an artifact with GroupID, ArtifactID and versions as marked in above pic.

Now we have another build which needs to trigger whenever that "some" build publishes to Nexus.



You add a new trigger by choosing "Maven Artifact Dependency Trigger" and provide the Nexus details where that "some" build is posting, like

  • GroupID (ex: temp), 
  • ArtifactID (ex: greeterApp) 
  • Version range 
    • We can configure versions in various ways. Refer TC documentation https://confluence.jetbrains.com/display/TCD18/Configuring+Maven+Triggers
    • In this case, we have configured it with [3.1,), this means trigger build whenever a version >= 3.1 gets published.
  • Type (ex: jar)
  • Maven repo url (ex: http://nexus.myorg.com/repository/third-party-lib)

Now whenever that "some" build publishes atifacts with latest version like "3.5", this build get's triggered.

In this case, the build overview page "Triggered by:" section says
Triggered by:        temp:greeterApp:[3.1,) on 05 Oct 18 06:21
Note: I have not documented the Nexus authentication required, since it was already setup in my case and I didn't need to worry about it.

2 comments:

Unknown said...

Aw, this was a very nice post. In thought I want to put in writing like this moreover – taking time and precise effort to make a very good article… however what can I say… I procrastinate alot and on no account appear to get one thing done. casino play

raynnowui21 said...

An impressive share, I just given this onto a colleague who was doing a bit of analysis on this. And he actually purchased me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the deal with! But yeah Thnkx for spending the time to debate this, I feel strongly about it and love reading extra on this topic. If attainable, as you grow to be expertise, would you thoughts updating your weblog with extra particulars? It's highly helpful for me. Large thumb up for this blog publish! play casino