DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Coding
  3. Java
  4. Maven Build Progress With TeamCity Service Messages

Maven Build Progress With TeamCity Service Messages

Evgeny Goldin user avatar by
Evgeny Goldin
·
May. 27, 12 · Interview
Like (0)
Save
Tweet
Share
5.17K Views

Join the DZone community and get the full member experience.

Join For Free
When you run a lengthy Maven build configuration in TeamCity it may be tricky to know what module is being built right now since all TeamCity displays is either “Running” or “Tests passed: X”.

Luckily, TeamCity allows your build script to interact with the server using Service Messages. When you build script prints out the following command, TeamCity reads it and behaves accordingly.

This way it is possible to report a compilation or testing results, publish artifacts (you can find "##teamcity[publishArtifacts" messages in IntelliJ IDEA build log), and even update build parameters on the fly. However, what I was interested in is build progress report:

Adding a single println to a Maven build can be done with a bit of Groovy scripting:

<plugin>
  <groupId>org.codehaus.gmaven</groupId>
  <artifactId>gmaven-plugin</artifactId>
  <version>1.4</version>
  <executions>
    <execution>
      <id>display-progress-report</id>
      <phase>initialize</phase>
      <goals>
        <goal>execute</goal>
      </goals>
      <configuration>
        <providerSelection>1.8</providerSelection>
        <source>
        if ( System.getProperty( 'teamcity.version' ))
        {
          println "##teamcity[progressMessage '${project.groupId}:${project.artifactId}']"
        }
        </source>
      </configuration>
    </execution>
  </executions>
</plugin>

After adding this snippet to project's parent POM, the progress indicator becomes (see it live!)

And I'm now working on making this functionality built-in for TeamCity 7.1.

Same trick can be used in Gradle, but it is less required since TeamCity already reports Gradle tasks progress. Anyway, if you're interested, grab this code:

allprojects {
    ...
    if ( project.properties.teamcity )
    {
        tasks.all { it.doFirst {
            logger.lifecycle( "##teamcity[progressMessage ':${project.name}:${it.name}']" )
        }}
    }
    ...
}
Build (game engine) TeamCity Apache Maven intellij

Published at DZone with permission of Evgeny Goldin, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Are SLOs, SLIs, and SLAs?
  • LazyPredict: A Utilitarian Python Library to Shortlist the Best ML Models for a Given Use Case
  • DeveloperWeek 2023: The Enterprise Community Sharing Security Best Practices
  • Integrating AWS Secrets Manager With Spring Boot

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: