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"
- Maven Snapshot Dependencies Trigger
- 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.