Marc Rufer bio photo

Marc Rufer

Software engineer
@d-fens GmbH

Twitter LinkedIn Github Stackoverflow
RSS Feed

HOWTO Maven Release on JetBrains TeamCity

Marc Rufer 19 Jun 2015 CI/CD JetBrains TeamCity Java maven

In this post I’ll show you how to set up a java build job for building and releasing a maven artifact. The activiti wrapper will be used as an example project. It’s a maven project that will be released by using the Maven Release plugin.

Before creating build configuraitons for java projects, the following conditions must be met on the host system:

HINT: The TeamCity instance used here has no external build agents configured and runs under system account.

Setup

Go to your TeamCity server and perform the follwing steps

  • Create a new project from URL
    • Enter the repository URL, the username and the password as demanded
  • Navigate to the settings of the newly crated project
  • Under VCS Roots you can edit the existing VCS root to define the branch to check out (in our case this would be the release branch)

    TC-mvn-release-vcs-1

    TC-mvn-release-vcs-2

  • Upload the maven settings.xml file which should be used for the release to the TeamCity server

    TC-mvn-release-mvn-settings

  • Go to General Settings, choose the auto detected build configuration and click on edit (NOTE: In this sample there are two configurations because one of them was added manually in advance)

    TC-mvn-release-general

  • Navigate to the Version Control Settings and change the VCS checkout mode to Automatically on Agent

    TC-mvn-release-vcs-chekcout-options

  • Go to the Build Steps menu, delete the existing build step and create two new build steps
    • Build step for release:prepare

      TC-mvn-release-prepare-step

    • Build step for release:perform

      TC-mvn-release-perform-step

  • Last but not least the parameters referenced in the build configuration (release:prepare) have to be defined
    • Go to Parameters menu and define the following parameters to be prompted
      • env.development.version
      • env.git.password
      • env.git.username
      • env.release.version

    TC-mvn-release-parameters

    The parameters were specified as follows

    TC-mvn-release-parameters-popup

Troubleshooting

Maven release:prepare hangs

Almost always the release:prepare goal of the maven release plugin hangs, the problem is that the GIT password is not set. In such a case the actual build has to be stopped and the password has to be set (i.e. according the manual above)

JRE instead of JDK

If the error message No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? occurs while the maven release plugin is preparing the release you have to install a java JDK on the build agents host system.

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Please tell me who you are

If the error message Please tell me who you are occurs on maven release:prepare the following commands have to be run on the build agents host system:

git config --system user.name "John Doe"

git config --system user.email john.doe@example.com

comments powered by Disqus

Posts

HOWTO Access Azure File Share in PowerShell Script executed by a Scheduled Task BUG "Task Scheduler service is not available" Error, if specifying Network Connection Condition HOWTO Sync OneDrive on Server even if Windows User not logged in HOWTO Access Microsoft Access Database with PowerShell Get NetworkCredential from PSCredential splits Username into Username and Domain HOWTO Create LocalDB File (.mdf) manually in Visual Studio 2015 HOWTO Set Cookie Header on DefaultRequestHeaders of HttpClient HOWTO Set up PowerShell Remote Session Configuration HOWTO Analyze PowerShell Scripts with PSScriptAnalyzer HOWTO Sign PDF with SuisseID NoBrainer PUT/PATCH/MERGE with OData Service Client Apply Commit from one Repository to another GitHub Repository creation with PowerShell HOWTO Sign PowerShell Script with SuisseID Swissunihockey game schedule PDF generator HOWTO Maven Release on JetBrains TeamCity Limitations when running Activiti in H2 Embedded Mode HOWTO Pylint Integration in IntelliJ 14 HOWTO Install Windows 10 IoT Core on Raspberry PI 2 from a VM First steps with Dropwizard Allman code style for IntelliJ First steps with Flyway IntelliJ - Setup custom inspection profiles Configuration properties meta-data support in IntelliJ AMQP Integration with spring integration OCA Java SE 7 Programmer I Certification Guide Swissunihockey key matcher Swisscom SMS-API-Client Some hints concerning logging with Log4j IFTTT A brilliant service Run deltacloud on a VirtualBox-VM Project specific maven settings in IntelliJ AngularJS Javascript for beginners Liferay in Action