9 comments
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.

0
Comment actions Permalink

Are there plans/timeline for native Gradle support?

Thanks,
Jon

0
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.

Thanks!

Peter

0
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 ?

0
Comment actions Permalink

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

0
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]:

......................

[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
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.

0
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"
  }
}

Thanks

0

Please sign in to leave a comment.