Using Gradle in Pipeline

120 views
Skip to first unread message

Sverre Moe

unread,
Apr 13, 2018, 2:02:43 AM4/13/18
to Jenkins Users
We are currently using Maven for building our applications. 

Our Jenkins maven pipeline are using the withMaven step from Pipeline Maven Integration.

I have written gradle build scripts for our projects and begun to write the Pipeline build script to build gradle.

We could really use an Pipeline Gradle Integration plugin and an withGradle step.

In the absence of such a plugin I am left with
tool name: 'gradle-4.6', type: 'gradle'
sh
"gradle build"

I think I have to put some verbosity to gradle. The Jenkins console output did not provide any insight while gradle was running the JUnit tests.

:processResources
:classes
:jar
:javadoc
:javadocJar
:sourcesJar
:assemble
:startMockServer
:processTestResources
:testClasses
:test
:stopMockServer
:check
:build

After :test there was no output for about 2 minutes. Not until task test was finished.
Not knowing if the build has halted, a test taking to long, or some other problem.

Would be great to have something like the dynamic output from running gradle
<=========----> 75% EXECUTING [15s]
> :test > 100 tests completed
> :test > Executing test com.company.api.ConnectionTest


Running Gradle with --console=rich gives me this output, but it is a mess.

:test [m [0K [7D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test [m [7D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test > 0 tests completed [m [27D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test > 0 tests completed [m [27D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test > 0 tests completed [m [27D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test > 0 tests completed [m [27D [1B [2A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [9s] [m [34D [1B [1m> :test > 0 tests 
...
...
> 330 tests completed [m [29D [1B [1m> :test > Executing test com.company.server.api.commands.Command1Test [m [0K [68D [1B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 29s] [m [38D [1B [1m> :test > 412 tests completed [m [29D [1B [1m> :test > Executing test com.company.server.api.commands.Command2Test [m [76D [1B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 29s] [m [38D [1B [1m> :test > 507 tests completed [m [29D [1B [1m> :test > Executing test com.company.server.api.commands.Command3Test [m [0K [68D [1B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 29s] [m [38D [1B [1m> :test > 661 tests completed [m [29D [1B> IDLE [0K [6D [1B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 29s] [m [38D [1B [1m> :test > 661 tests completed [m [29D [2B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 29s] [m [38D [1B [1m> :test > 661 tests completed [m [29D [2B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 30s] [m [38D [1B [1m> :test > 661 tests completed [m [29D [2B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 30s] [m [38D [1B [1m> :test [m [0K [7D [2B [3A [1m< [0;32;1m========= [0;39;1m----> 75% EXECUTING [1m 30s] [m [38D [1B [1m> :test [m [7D [2B [3A [0K
[0K
[32;1mBUILD SUCCESSFUL [0;39m in 1m 32s
11 actionable tasks: 11 executed



Are anyone using gradle in their Jenkins pipeline?

Francesco Sisca

unread,
Apr 13, 2018, 7:30:25 AM4/13/18
to Jenkins Users

check configuration of gradle in your global configuration tools (into jenkins manage)



this is my pipeline:


pipeline {

    agent any
        tools {
        gradle "gradle"
    }
    environment{
        ANDROID_HOME="/opt/sdk-tools-linux-3859397"
        PATH="${PATH}:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools"
    }

Brian Ray

unread,
May 16, 2018, 1:56:45 PM5/16/18
to Jenkins Users
We are, extensively.

I may be interpreting the issue wrong, but it seems like a more "native" pipeline API is not necessarily the blocker here.

Does this help at all?:

sh "gradle build --info --console=plain"

Those switches increase logging verbosity and eliminate the control characters that Jenkins console renders poorly.

More doc on Gradle's logging and other command line options is here.
Reply all
Reply to author
Forward
0 new messages