Error running multi project gradle build in jenkins pipeline


(Gloria Santin) #1

I have a multi project gradle build running locally successfully. There are 3 build scripts. A parent build called build.gradle at the root of the project. Then 2 build scripts in specific folders. Load/load_build.gradle and LoadRemote/loadRemote_build.gradle
There is a settings.gradle file that defines the hierarchy:

rootProject.name = ‘EquipLoad’

include ‘load’
project(’:load’).projectDir = new File(".", “/Load”)
project(’:load’).buildFileName = ‘load_build.gradle’

include ‘loadRemote’
project(’:loadRemote’).projectDir = new File(".", “/LoadRemote”)
project(’:loadRemote’).buildFileName = ‘remoteLoad_build.gradle’

Locally, I can successfully build both ear files using the command:
gradlew buildAll

This task is defined in the parent build script (build.gradle) shown below:

gradle.projectsEvaluated {
task compileAll (dependsOn: [project(’:loadRemote’).remoteLoadCleanCompileStage]) {
compileAll.finalizedBy project(’:load’).loadCleanCompileStage
}

task packageAll (dependsOn: [project(’:loadRemote’).remoteLoadPackage]) {
packageAll.finalizedBy project(’:load’).loadPackage
}

task buildAll (dependsOn: [compileAll]) {
buildAll.finalizedBy packageAll
}
}

When I try to run the gradle command in a jenkins pipeline, I get the error:
Could not get unknown property 'remoteLoadCleanCompileStage' for project ':loadRemote' of type org.gradle.api.Project.

Looking at the debug statements in the jenkins build, the Load and LoadRemote build files are identified and configured:
For Load:
Build operation ‘Apply plugin org.gradle.help-tasks to project ‘:load’’ completed
12:12:55.054 [INFO] [org.gradle.configuration.project.BuildScriptProcessor] Evaluating project ‘:load’ using build file ‘/var/…workspace/ranch_Pipeline_jenkinsBuild-RAM62NEGEBRKABS6QMGC7U64EAT3NBQJQNCQV4J4RXXF3P332HAQ/load/load_build.gradle’.
12:12:55.056 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 0.002 secs
12:12:55.056 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation ‘Configure project :load’
12:12:55.056 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation ‘Configure project :load’ completed

For LoadRemote:
Build operation ‘Apply plugin org.gradle.help-tasks to project ‘:loadRemote’’ completed
12:12:55.058 [INFO] [org.gradle.configuration.project.BuildScriptProcessor] Evaluating project ‘:loadRemote’ using build file ‘/…/workspace/ranch_Pipeline_jenkinsBuild-RAM62NEGEBRKABS6QMGC7U64EAT3NBQJQNCQV4J4RXXF3P332HAQ/loadRemote/remoteLoad_build.gradle’.
12:12:55.058 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 0.0 secs
12:12:55.059 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation ‘Configure project :loadRemote’
12:12:55.060 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation ‘Configure project :loadRemote’ completed

The task defined for the loadRemote project in the parent build is not recognized.

Can you see where the problem is?