No idea how to reproduce this even. It's on Windows tho.

**Build scan:**
https://gradle-enterprise.elastic.co/s/jfm5i67ybasa4/tests/:integTest/org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest/bwc%20expanded%20distribution%20folder%20can%20be%20resolved%20as%20bwc%20project%20artifact

**Reproduction line:**
`null`

**Applicable branches:**
7.16

**Reproduces locally?:**
Didn't try

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest&tests.test=bwc%20expanded%20distribution%20folder%20can%20be%20resolved%20as%20bwc%20project%20artifact

**Failure excerpt:**
```
org.gradle.testkit.runner.UnexpectedBuildFailure: Unexpected build execution failure in C:\Users\jenkins\AppData\Local\Temp\junit10293579225588038864\cloned with arguments [:resolveExpandedDistribution, -DtestRemoteRepo=C:\Users\jenkins\AppData\Local\Temp\junit12751380988170521671\remote\.git, -Dbwc.remote=origin, -Dtest.external=true]

Output:
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:processResources
> Task :buildSrc:classes
> Task :buildSrc:jar
> Task :buildSrc:assemble
> Task :buildSrc:compileTestJava NO-SOURCE
> Task :buildSrc:compileTestGroovy NO-SOURCE
> Task :buildSrc:processTestResources NO-SOURCE
> Task :buildSrc:testClasses UP-TO-DATE
> Task :buildSrc:test NO-SOURCE
> Task :buildSrc:check UP-TO-DATE
> Task :buildSrc:build
=======================================
Elasticsearch Build Hamster says Hello!
  Gradle Version        : 7.3.2
  OS Info               : Windows Server 2016 10.0 (amd64)
  Runtime JDK Version   : 1.8.0_301 (Oracle)
  Runtime java.home     : C:\Users\jenkins\.java\java8
  Gradle JDK Version    : 16.0.2 (Oracle)
  Gradle java.home      : C:\Users\jenkins\.java\openjdk16
  Random Testing Seed   : 7CCAE3A0EAEC43FD
  In FIPS 140 mode      : false
=======================================
> Task :distribution:bwc:minor:createClone
> Task :distribution:bwc:minor:findRemote
> Task :distribution:bwc:minor:addRemote SKIPPED
> Task :distribution:bwc:minor:fetchLatest

> Task :distribution:bwc:minor:checkoutBwcBranch
Performing checkout of origin/7.x...
Checkout hash for :distribution:bwc:minor is e76c0a56b900e06249421b14ca2992832da75e86

> Task :distribution:bwc:minor:buildBwcDarwinTar
 [7.12.0] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 -Dsun.jnu.encoding=UTF8
 [7.12.0] 
 [7.12.0] FAILURE: Build failed with an exception.
 [7.12.0] 
 [7.12.0] * Where:
 [7.12.0] Initialization script 'C:\Users\jenkins\.gradle\init.d\init.gradle' line: 25
 [7.12.0] 
 [7.12.0] * What went wrong:
 [7.12.0] A problem occurred evaluating initialization script.
 [7.12.0] > Vault responded with HTTP status code: 500
 [7.12.0] 
 [7.12.0] * Try:
 [7.12.0] > Run with --stacktrace option to get the stack trace.
 [7.12.0] > Run with --info or --debug option to get more log output.
 [7.12.0] > Run with --scan to get full insights.
 [7.12.0] 
 [7.12.0] * Get more help at https://help.gradle.org
 [7.12.0] 
 [7.12.0] BUILD FAILED in 27s
Output for cmd:

> Task :distribution:bwc:minor:buildBwcDarwinTar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':distribution:bwc:minor:buildBwcDarwinTar'.
> Process 'cmd [/C, call, C:\Users\jenkins\AppData\Local\Temp\junit10293579225588038864\cloned\distribution\bwc\minor\build\bwc\checkout-7.x\gradlew, -Dbuild.snapshot=true, -Dscan.tag.NESTED, distribution:archives:darwin-tar:extractedAssemble]' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 31s
7 actionable tasks: 7 executed

  at org.gradle.testkit.runner.internal.DefaultGradleRunner.lambda$build$2(DefaultGradleRunner.java:264)
  at org.gradle.testkit.runner.internal.DefaultGradleRunner.run(DefaultGradleRunner.java:338)
  at org.gradle.testkit.runner.internal.DefaultGradleRunner.build(DefaultGradleRunner.java:262)
  at org.elasticsearch.gradle.internal.test.InternalAwareGradleRunner.build(InternalAwareGradleRunner.java:145)
  at org.elasticsearch.gradle.internal.test.NormalizeOutputGradleRunner.build(NormalizeOutputGradleRunner.java:145)
  at org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest.bwc expanded distribution folder can be resolved as bwc project artifact(InternalDistributionBwcSetupPluginFuncTest.groovy:170)

```
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/BwcSetupExtension.java
TaskProvider<LoggedExec> bwcTask(String name, Action<LoggedExec> configuration) {
        return createRunBwcGradleTask(project, name, configuration);
    }
    private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String name, Action<LoggedExec> configAction) {
        return project.getTasks().register(name, LoggedExec.class, loggedExec -> {
            loggedExec.dependsOn("checkoutBwcBranch");
            loggedExec.usesService(bwcTaskThrottleProvider);
            loggedExec.setSpoolOutput(true);
            loggedExec.setWorkingDir(checkoutDir.get());
            loggedExec.doFirst(new Action<Task>() {
                @Override
                public void execute(Task t) {
                    
                    String compilerVersionInfoPath = minimumCompilerVersionPath(unreleasedVersionInfo.get().version());
                    String minimumCompilerVersion = readFromFile(new File(checkoutDir.get(), compilerVersionInfoPath));
                    loggedExec.environment("JAVA_HOME", getJavaHome(Integer.parseInt(minimumCompilerVersion)));
                }
            });
            if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                loggedExec.executable("cmd");
                loggedExec.args("/C", "call", new File(checkoutDir.get(), "gradlew").toString());
            } else {
                loggedExec.executable(new File(checkoutDir.get(), "gradlew").toString());
            }
            if (project.getGradle().getStartParameter().isOffline()) {
                loggedExec.args("--offline");
            }
            
            String buildCacheUrl = System.getProperty("org.elasticsearch.build.cache.url");
            if (buildCacheUrl != null) {