TLDR: How can I override gradle.properties in a bitbucket gradle build?
I have a few questions regarding configuring gradle builds for bitbucket. We are executing
GRADLE_OPTS="$GRADLE_OPTS" ./gradlew clean build --parallel
as one of the bitbucket pipeline steps (this runs for each PR). Recently, I have run into a memory issue which, due to Bitbucket’s inability to provide basic configuration features, unfortunately forces me to configure different gradle settings for the bitbucket build. By default, the build picks up the properties declared in gradle.properties, and it seems that no matter how I define the pipeline step in bitbucket, I am unable to override the jvm args set in that file.
I have also been unsuccessful at making gradle respect the worker limit when run in bitbucket. I am trying to make the maximum number of workers be 3, but it always end up as below:
Workers 4 and 10 are run with slightly different command line parameters, which I also do not understand.
Bitbucket support has refused to help me with this issue further, though overriding gradle.properties appears to work as expected locally. I was wondering if anybody else has had a similar issue or knew how to resolve it.
The reason I do not want to just edit gradle.properties is because we also run builds locally, and there’s no reason to reduce the memory cap or limit the number of workers in this case.
Things I have tried so far:
- Passing in “–max-workers=3” as an argument.
- Passing in “-Dorg.gradle.workers.max=3” as an argument (this is not set in gradle.properties, so I figured this would just work.)
- Setting GRADLE_OPTS="-Xmx=2g … -Dorg.gradle.workers.max=3" instead of GRADLE_OPTS="$GRADLE_OPTS".
- Doing the same as above except exporting GRADLE_OPTS as a separate bash command before running the build.
Irregardless of what I do, I always see the following two commands being executed in the pipeline:
java -Xmx64m -Xms64m -Xmx2g -XX:MetaspaceSize=100m -XX:MaxPermSize=1g ... org.gradle.wrapper.GradleWrapperMain clean build
java -XX:MetaspaceSize=100m -XX:MaxPermSize=1g -Xmx3g ... org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.5.1
I have no idea where the arguments for the first command are coming from (I am assuming they are bitbucket defaults maybe?). And the arguments for the second command always come from gradle.properties, irregardless of what I do.
Any help or pointers would be highly appreciated.