Skip to content

Improve isolation for nested Gradle runs#11564

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
masterfrom
bdu/gradle-colored-console-gitlab
Jun 4, 2026
Merged

Improve isolation for nested Gradle runs#11564
gh-worker-dd-mergequeue-cf854d[bot] merged 8 commits into
masterfrom
bdu/gradle-colored-console-gitlab

Conversation

@bric3
Copy link
Copy Markdown
Contributor

@bric3 bric3 commented Jun 4, 2026

What Does This Do

Isolates nested Gradle invocations used by smoke-test application builds and Gradle TestKit fixtures from CI-provided Gradle launcher environment variables.

The main changes are:

  • Clear inherited GRADLE_OPTS and GRADLE_ARGS before nested Tooling API and TestKit Gradle builds run.
  • Give nested smoke-test application builds a task-local GRADLE_USER_HOME, stop nested Gradle daemons, and delete that user home after the build.

Motivation

GitLab CI exports Gradle launcher settings for the root Gradle 9 build. Those settings can be inherited by nested Gradle builds launched through the Tooling API or Gradle TestKit, including smoke-test applications pinned to older Gradle versions. That inheritance caused nested Gradle 8.14.5 builds to reject unsupported console settings before the application build could run.

The fix keeps nested builds isolated from root-build launcher state while preserving the CI root build behavior.

Additional Notes

Colored output uses Gradle's colored plain-console support introduced in Gradle 9.1.0 (--console=colored):

Screenshot 2026-06-04 at 14 33 40 Screenshot 2026-06-04 at 14 35 39

At this time, I chose not to clear these variables as they are not explicitly set in the gitlab ci at this time.

  • GRADLE_OPTS
  • GRADLE_ARGS
  • JAVA_HOME
  • JAVA_OPTS
  • JAVA_TOOL_OPTIONS
  • JDK_JAVA_OPTIONS
  • _JAVA_OPTIONS

Nor do I choose to filter on ORG_GRADLE_PROJECT_ because some are intentionnaly needed in the nested build, in particular for the repositories.gradle script plugin.

Contributor Checklist

Jira ticket: [PROJ-IDENT]

bric3 added 7 commits June 4, 2026 14:27
Gradle 9.1.0 introduced the colored console mode for color highlighting in plain logs without rich progress bars: https://docs.gradle.org/9.1.0/release-notes.html#plain-console-with-colors

Use that mode through GRADLE_OPTS so GitLab jobs can render ANSI color while keeping the existing JVM argument configuration.
Keep --console=colored as an explicit argument for direct GitLab Gradle invocations instead of putting org.gradle.console in GRADLE_OPTS.

Nested smoke-test application builds run through the Gradle Tooling API with Gradle 8.14.5, where the colored console value is not valid and fails before the nested build can run.
Nested smoke-test application builds run through the Gradle Tooling API and can otherwise inherit CI launcher variables from the outer build.

Clear GRADLE_OPTS and GRADLE_ARGS by default before starting the nested Gradle build, while still allowing explicit smokeTestApp environment overrides.
Inline the GitLab colored console flag as --console=colored and keep it out of Gradle properties.

Clear GRADLE_OPTS and GRADLE_ARGS for GradleRunner and wrapper helper invocations so nested Gradle builds do not inherit incompatible CI launcher settings.
Run nested smoke-test application builds with a task-local Gradle user home and delete it after the Tooling API build finishes.

This prevents inherited CI Gradle user-home state from leaking into pinned nested Gradle versions alongside GRADLE_OPTS and GRADLE_ARGS.
Write org.gradle.console=colored into the CI-generated root gradle.properties instead of passing --console=colored on Gradle command lines.

Keep the nested smoke-test GradleRunner regression focused on clearing inherited launcher arguments without using the console flag as the sentinel.
Stop the nested Gradle daemon with the downloaded Gradle distribution before deleting the task-local Gradle user home.

Also configure colored console output for the test-published-dependencies Gradle root.
@bric3 bric3 added type: bug Bug report and fix comp: build tag: ai generated Largely based on code generated by an AI or LLM labels Jun 4, 2026 — with ChatGPT Codex Connector
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Jun 4, 2026

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.93 s 13.97 s [-1.4%; +0.8%] (no difference)
startup:insecure-bank:tracing:Agent 12.95 s 12.94 s [-1.0%; +1.1%] (no difference)
startup:petclinic:appsec:Agent 16.49 s 16.31 s [-0.3%; +2.4%] (no difference)
startup:petclinic:iast:Agent 16.43 s 16.64 s [-2.3%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 16.48 s 16.44 s [-1.0%; +1.5%] (no difference)
startup:petclinic:tracing:Agent 15.78 s 15.63 s [-0.3%; +2.1%] (no difference)

Commit: a90a324d · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@bric3 bric3 added tag: no release notes Changes to exclude from release notes and removed comp: build labels Jun 4, 2026
@bric3 bric3 changed the title Isolate nested Gradle smoke-test environments Improve isolation for nested Gradle runs Jun 4, 2026
@bric3 bric3 marked this pull request as ready for review June 4, 2026 14:48
@bric3 bric3 requested review from a team as code owners June 4, 2026 14:48
@bric3 bric3 requested review from amarziali and randomanderson and removed request for a team June 4, 2026 14:48
@datadog-datadog-prod-us1-2

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@amarziali amarziali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for colors ;)

@amarziali amarziali marked this pull request as draft June 4, 2026 15:24
@amarziali amarziali marked this pull request as ready for review June 4, 2026 15:25
Clear inherited Gradle user-home state from TestKit and build-logic smoke runs, and align the Gradle plugin smoke fixture expectations after adding the sanitized environment.
@bric3
Copy link
Copy Markdown
Contributor Author

bric3 commented Jun 4, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Jun 4, 2026

View all feedbacks in Devflow UI.

2026-06-04 17:13:54 UTC ℹ️ Start processing command /merge


2026-06-04 17:14:05 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-04 17:15:09 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-06-04 18:31:57 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit d65e036 into master Jun 4, 2026
574 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the bdu/gradle-colored-console-gitlab branch June 4, 2026 18:31
@github-actions github-actions Bot added this to the 1.64.0 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tag: ai generated Largely based on code generated by an AI or LLM tag: no release notes Changes to exclude from release notes type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants