Cannot run tests with latest gradle nightly on OpenShift

Cannot run tests with latest gradle nightly on OpenShift. TcpOutgoingConnector tries to open a random port, however OpenShift environments restrict access to single, specific port, via an environment variable.

See related issue: https://issues.gradle.org/browse/GRADLE-2871

Stack trace from the failure:

:testClasses UP-TO-DATE
:testorg.gradle.messaging.remote.internal.ConnectException: Could not connect to server [01104c45-0444-4e0c-917b-0d78784ce581 port:18892, addresses:[/127.0.0.1]]. Tried addresses: [/127.0.0.1].
    at org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector.connect(TcpOutgoingConnector.java:62)
    at org.gradle.messaging.remote.internal.hub.MessageHubBackedClient.getConnection(MessageHubBackedClient.java:35)
    at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:54)
    at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
    at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:85)
    at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:41)
    at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:43)
    at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:32)
    at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:46)
    at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:32)
    at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
    at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
Caused by: java.net.ConnectException: Connection refused

Compilation passes successfully on the same environment.

TcpOutgoingConnector should use the same strategy/logic as the TcpIncomingConnector, detecting the OpenShift environment variable and setting the port number accordingly.

Thanks, I’ve raised GRADLE-3180 for this. If you were able to contribute a pull request to fix this, that would be great.