Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Gradle build fails randomly in Pipelines

xtjhin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 10, 2016

A Gradle might unexpectedly and 'randomly' fail despite working locally when run in the same Docker container

> Building 52%* Try:
> Building 52%Run with 
> Building 52%--stacktrace
> Building 52% option to get the stack trace. Run with 
> Building 52%--info
> Building 52% or 
> Building 52%--debug
> Building 52% option to get more log output.
> Building 52%
> Building 52%BUILD FAILED
> Building 52%
> Building 52%
> Building 52%Total time: 2 mins 24.579 secs
> Building 52%
FAILURE: 
Build failed with an exception.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
xtjhin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 10, 2016

This could be due to the fork test feature of Gradle which explains why it fails "randomly" as it all depends on which test fork finally pushes your build above our limits, could you tweak the following settings and see if that alleviates the issue:

https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html

  • maxHeapSize
  • minHeapSize
  • maxForks
  • forkEvery

Some suggestions from the internet are:

subprojects { project ->
    test {
            maxParallelForks = 2
            maxHeapSize = '768m'
            forkEvery = 100   // helps when tests leak memory
            afterSuite {
                System.out.print('.')
                System.out.flush()
            }
    }
}
0 votes
Malte Hübner March 7, 2017

We are also facing this problem (gradle build finishes SUCCESSFUL but pipeline exits with status FAILED - "Build memory limit exceeded"). This is a non reproducable issue (locally).

  • GRADLE_OPTS ist set to "-Dorg.gradle.daemon=true -Xmx2048m -Xms512m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant"
  • running multi project build (gradle wrapper + Grails 3)

build.gradle contains:

subproject.tasks.withType(GroovyCompile) { task ->
    task.configure {
        groovyOptions.fork(memoryMaximumSize: '1024m')
        groovyOptions.encoding = "UTF-8"
    }
}
subproject.tasks.withType(JavaCompile) { task ->
    task.configure {
        options.fork(memoryMaximumSize: '256m')
        options.encoding = 'UTF-8'
    }
}
test {
    if (isPipelineBuild) {
        println "Configuring task 'test' for Pipeline build."
        maxParallelForks = 2
        forkEvery = 25
        minHeapSize = '128m'
        maxHeapSize = '1.5G'
    }
}

Console output:

BUILD SUCCESSFUL
Total time: 8 mins 47.51 secs
FAILURE: Build failed with an exception.
* What went wrong:
Process 'Gradle Compiler Daemon 1' finished with non-zero exit value 137
0 votes
Galya Bogdanova October 6, 2016

I had the issue before, when the memory limit of the build was 2GB, but now it should be gone. Unfortunately it's still present in Pipelines, while it's working flawlessly locally with 4GB of memory for the docker environment and 3GB for the Gradle daemon.

The error is "FAILURE: Build failed with an exception.". When you run with  --stacktrace --debug you get the more 'detailed' explanation: "org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)". It happens to me also in the middle of the build script execution (60%).

P.S. I don't run tests.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events