Skip to content

[release/10.0.1xx-sr6] Cache Gradle downloads between CI runs to avoid transient failures - #35016

Merged
PureWeen merged 4 commits into
release/10.0.1xx-sr6from
backport/pr-34804-to-release/10.0.1xx-sr6
Apr 17, 2026
Merged

[release/10.0.1xx-sr6] Cache Gradle downloads between CI runs to avoid transient failures#35016
PureWeen merged 4 commits into
release/10.0.1xx-sr6from
backport/pr-34804-to-release/10.0.1xx-sr6

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Backport of #34804 to release/10.0.1xx-sr6

/cc @PureWeen

github-actions Bot and others added 4 commits April 17, 2026 14:21
Add a shared cache-gradle.yml template using Cache@2 to persist
~/.gradle/caches between pipeline runs. This prevents transient
DNS/network failures from breaking builds when Gradle resolves
Maven Central dependencies during Android binding compilation.

The cache key includes Agent.OS, gradle-wrapper.properties, and
build.gradle files so it auto-invalidates on Gradle version or
dependency changes.

Adapted from dotnet/android: 0a681023be145d62d0d55a6e49bfc7f2b9aac86f

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…, fix display names

- Add settings.gradle and gradle.properties to cache key to avoid stale
  cache when repository config or Jetifier flag changes
- Cache entire ~/.gradle (not just caches/) to include wrapper/dists and
  avoid transient failures downloading the Gradle distribution itself
- Guard cache template with skipAndroidCommonSdks so non-Android jobs
  (iOS, MacCatalyst, Windows) skip the cache steps entirely
- Disambiguate step display names for Linux/macOS vs Windows
- Add intermediate restoreKeys entry keyed on gradle-wrapper.properties
  so dependency-only changes still get a partial cache hit
- Document the v1 version segment as the manual cache-bust mechanism

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The RunOnAndroid integration test job doesn't invoke Gradle directly,
so ~/.gradle is never created. When Cache@2 runs its post-job save,
tar fails with 'No such file or directory' (exit code 2).

Pre-create the directory in the variable-setting steps so the post-job
save always has a valid (possibly empty) directory to tar.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address review feedback from @jonathanpeppers: use YAML folded scalar
(>-) to split the long cache key string across multiple lines, one per
file segment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PureWeen

Copy link
Copy Markdown
Member

/azp run maui-pr-uitests, maui-pr-devicetests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@PureWeen
PureWeen merged commit 0811b9d into release/10.0.1xx-sr6 Apr 17, 2026
135 of 167 checks passed
@PureWeen
PureWeen deleted the backport/pr-34804-to-release/10.0.1xx-sr6 branch April 17, 2026 20:52
@github-actions github-actions Bot added this to the .NET 10 SR6 milestone Apr 17, 2026
PureWeen added a commit that referenced this pull request Apr 21, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Problem

The official build (`dotnet-maui`, definition 1095) for
`release/10.0.1xx-sr6` has been failing with Gradle network errors on
Windows:

```
Permission denied: getsockopt
Could not GET https://repo.maven.apache.org/maven2/...
gradlew.bat exited with code 1
```

Build
[2954057](https://dev.azure.com/dnceng/internal/_build/results?buildId=2954057)
failed even though it included the Gradle cache fix from PR #35016. The
cache step was added to `provision.yml`, but the official Pack job uses
`pack.yml` directly — which never calls `provision.yml`.

## Fix

Add the same `cache-gradle.yml` template call to
`eng/pipelines/common/pack.yml` before the pack step, matching the
pattern already used in `provision.yml`.

## Impact

This unblocks the 10.0.60 official build by ensuring the Gradle
dependency cache is warm before the Pack step invokes Gradle on Windows
agents with network isolation.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant