Help with parallel docker (via Gradle) builds?

(Chris F) #1

I’m fairly new to Gradle, though have lots of Maven experience so I understand the concept. We have the following, OLD I know, but we are slowly transitioning to 4.10.x

Also this is NOT a Jenkins pipeline question, in spite of the Jenkins pipeline code, but I just wanted to show what we’re doing in context.

$ ./gradlew --version

Gradle 2.9

Build time:   2015-11-17 07:02:17 UTC
Build number: none
Revision:     b463d7980c40d44c4657dc80025275b84a29e31f

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Mac OS X 10.13.6 x86_64

We have a Jenkins file that tries to do parallel builds for our Docker images via Gradle. We do, this, which calls the buildDocker task in our build.gradle files.

def buildDockerImages(gradleProjectFlag, version)
  sh "./gradlew buildDocker ${gradleProjectFlag} -P{$vwrsion} --parallel"

node('linux') {
  stage('Build Docker images') {
        "module1" :   {
            buildDockerImage("module1", "1.0.0")
        "module2" :   {
            buildDockerImage("module2", "1.0.0")

and our buildDocker task is…

task buildDocker(type: Docker, dependsOn: war) {
    doFirst {
        copy {
            from war
            rename { name -> 'app.war' }
            into stageDir
    def dockerTag = project.hasProperty('applicationName') ? project.applicationName :
    tag = dockerTag
    dockerfile = file("$rootDir/deploy/docker/webapp/Dockerfile")
    doLast {
        exec {
            commandLine 'docker', 'tag', tag, "${dockerTag}:latest"

A lot of times, our builds will fail and the only error I get on the Jenkins console is, which is SIGTERM (143-128=15, SIGTERM, 128 is what Jenkins adds to the signal received by the process if I understand correctly. See

ERROR: script returned exit code 143

My question is there anything ELSE I need to do to ensure our parallel builds work 100%? We do daemonize our Gradle process.