Comment actions Permalink

Gradle can be started using command line runner. To import tests you can configure build script to produce JUnit xml reports. Then you can specify paths to report directories in command line runner settings, and tests will be picked up. So answering to your question - currently there is no native support for Gradle, but the approach I described provides reasonable integration.

Comment actions Permalink

Are there plans/timeline for native Gradle support?


Comment actions Permalink

+1 on this request. Gradle is shaping up to be a nice alternative to Maven, but the lack of key tool support could be a real limit to adoption. Representing one TeamCity-using-company that would see non-native gradle support a negative.



Comment actions Permalink

I tried to add a gradle build in TeamCity Enterprise Version 4.5.5 (build 9103)
build runner : command line
Command executable:gradle.bat
Command parameters:-q sometest -S

At general settings I checked all options from "Fail build if" section

Still, the build always passes, even if the gradle build fails.

Any solution for this ?

Comment actions Permalink

Could you please check what exit code gradle.bat returns if build fails?

Comment actions Permalink
Here is a part of the log

[10:27:24]: [ERROR] BUILD ERROR
[10:27:24]: FAILURE:  Build failed with an exception.
[10:27:24]: *  Where:
[10:27:24]: Build  file 'E:\TeamCityBuildAgent\work\33d954fe3159c871\build.gradle' line:  229
[10:27:24]: *  What went wrong:
[10:27:24]: Execution  failed for task ':env_upgrade'.
[10:27:24]: Cause:  Java returned: 1
[10:27:24]: *  Exception is:
[10:27:24]: org.gradle.api.GradleScriptException:  Build file 'E:\TeamCityBuildAgent\work\33d954fe3159c871\build.gradle'  line: 229


[10:27:24]: ... 36 common frames omitted
[10:27:24]: BUILD  FAILED
[10:27:24]: Process exited with code 0
[10:27:25]: Build finished

Apparently gradle exists with 0
Comment actions Permalink

TeamCity could rely on exit code, but since gradle reports 0 for failed build, this approach does not work.

I think this will be useful: http://www.jetbrains.net/confluence/display/TCD5/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingBuildStatus
In brief, if you can detect failure in the build script and write something to the process output, you can instruct TeamCity to fail the build. You can also pass status line to be shown in the TeamCIty web UI.

Comment actions Permalink

it worked with

gradle.taskGraph.afterTask {task, exception ->
  if (exception) {
    println "[ERROR] BUILD ERROR"
    println "##teamcity[buildStatus status='FAILURE' text='FAILURE omg!!!']"
  else {
    println "done"



Please sign in to leave a comment.