Gradle build problem

Answered

Hi,

 

Our gradle build has started behaving weirdly. TeamCity still sees the build as successful even though the build has only run for about 1 second. I had a look in the build log and found this.

========================================================
[19:09:53] : Build preparation done
[19:09:53]W: Step 1/1: Gradle
[19:09:53]i:     [Step 1/1] ##teamcity[buildStatisticValue key='buildStageDuration:firstStepPreparation' value='52.0']
[19:09:53]i:     [Step 1/1] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_1' value='0.0']
[19:09:53] :     [Step 1/1] Starting: C:\TCWork\A3\d8fd70f1699db8d9\gradlew.bat --init-script C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle -d clean buildServerCapsule
[19:09:53] :     [Step 1/1] in directory: C:\TCWork\A3\d8fd70f1699db8d9
[19:09:53]W:     [Step 1/1] Access is denied. <------------------------------------------------------------------------
[19:09:53] :     [Step 1/1] Process exited with code 0
[19:09:54]i:     [Step 1/1] ##teamcity[buildStatisticValue key='buildStageDuration:buildStepRUNNER_1' value='72.0']
[19:09:54]i: ##teamcity[buildStatisticValue key='buildStageDuration:buildFinishing' value='7.0']
[19:09:54] : Publishing internal artifacts
[19:09:54] :     [Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[19:09:54] :     [Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[19:09:54]W: Publishing artifacts
[19:09:54] :     [Publishing artifacts] Collecting files to publish: [olap-server\build\libs\olap-server.jar => release]
[19:09:54]W:     [Publishing artifacts] Artifacts path 'olap-server/build/libs/olap-server.jar' not found
[19:09:54]i: ##teamcity[buildStatisticValue key='buildStageDuration:artifactsPublishing' value='44.0']
[19:09:54] : Build finished

======================================================== 

So I jumped on the agent machine, went to the same directory and executed the same command.

 

========================================================

C:\TCWork\A3\d8fd70f1699db8d9>C:\TCWork\A3\d8fd70f1699db8d9\gradlew.bat --init-script C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle -d clean buildServerCapsule
19:39:45.683 [DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Native-platform posix files is not available.  Continuing with fallback.
19:39:46.308 [INFO] [org.gradle.BuildLogger] Starting Build
19:39:46.308 [DEBUG] [org.gradle.BuildLogger] Gradle user home: C:\Users\admin\.gradle
19:39:46.324 [DEBUG] [org.gradle.BuildLogger] Current dir: C:\TCWork\A3\d8fd70f1699db8d9
19:39:46.324 [DEBUG] [org.gradle.BuildLogger] Settings file: null
19:39:46.340 [DEBUG] [org.gradle.BuildLogger] Build file: null
...
19:39:47.605 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on cp_init class cache for initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' (C:\Users\admin\.gradle\caches\2.12\scripts\init_5nzv86jq87dekjlqjfr85cpmd\cp_init).
19:39:47.636 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
19:39:47.965 [DEBUG] [org.gradle.api.internal.artifacts.mvnsettings.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: C:\Users\admin\.m2\repository
19:39:48.105 [INFO] [org.gradle.api.Script] Init lib: null
19:39:48.137 [ERROR] [org.gradle.BuildExceptionReporter]
19:39:48.152 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
19:39:48.168 [ERROR] [org.gradle.BuildExceptionReporter]
19:39:48.199 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
19:39:48.199 [ERROR] [org.gradle.BuildExceptionReporter] Initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' line: 32
19:39:48.230 [ERROR] [org.gradle.BuildExceptionReporter]
19:39:48.246 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
19:39:48.262 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating initialization script.
19:39:48.277 [ERROR] [org.gradle.BuildExceptionReporter] > Cannot invoke method split() on null object
19:39:48.293 [ERROR] [org.gradle.BuildExceptionReporter]
19:39:48.324 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
19:39:48.324 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
19:39:48.355 [LIFECYCLE] [org.gradle.BuildResultLogger]
19:39:48.371 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
19:39:48.387 [LIFECYCLE] [org.gradle.BuildResultLogger]
19:39:48.418 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 3.0 secs
19:39:48.418 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_init class cache for initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' (C:\Users\admin\.gradle\caches\2.12\scripts\init_5nzv86jq87dekjlqjfr85cpmd\cp_init).
19:39:48.449 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 0, cache instances: 0, modules served from cache: 0, artifacts: 0
19:39:48.480 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 0 resolution results binary files in 0.0 secs
19:39:48.496 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache artifact cache (C:\Users\admin\.gradle\caches\modules-2) was closed 0 times.
19:39:48.512 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (C:\Users\admin\.gradle\caches\2.12\plugin-resolution) was closed 0 times.
========================================================

Looking in C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle I can see that it's looking for an environment variable called TEAMCITY_BUILD_INIT_PATH which does not seem to exist.

I also noticed a suspicious line above:
19:39:46.340 [DEBUG] [org.gradle.BuildLogger] Build file: null

Is that normal?

Any help would be much appreciated.
Cheers
Oliver

3 comments

Hi Oliver,

Did you run the same command on agent under the same user that the agent is running under? Please follow the steps from the guidelines to investigate the issue.

0


Hi Alina,

Thanks for the reply. Yes I've checked the user is the same. Please see the outputs below. I've also attached a screenshot to show the user the agents are running under.

 

-------------------------------------------------
From the build log in TeamCity (note, this build is marked as successful even though it clearly fails)
[09:29:00][Step 1/1] Starting: C:\TCWork\A3\d8fd70f1699db8d9\gradlew.bat --init-script C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle -d clean buildServerCapsule
[09:29:00][Step 1/1] in directory: C:\TCWork\A3\d8fd70f1699db8d9
[09:29:00][Step 1/1] The system cannot find the file specified. <-------------------------------------------------
[09:29:00][Step 1/1] Process exited with code 0

-------------------------------------------------

On the agent machine

Running the same command on a console on the build agent machine. Fails because of the TEAMCITY_BUILD_INIT_PATH environment variable not being defined. Who defines this?

C:\Users\admin>
C:\Users\admin>echo %username%
admin

C:\Users\admin>cd  C:\TCWork\A3\d8fd70f1699db8d9

C:\TCWork\A3\d8fd70f1699db8d9> C:\TCWork\A3\d8fd70f1699db8d9\gradlew.bat --init-script C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle -d clean buildServerCapsule
09:44:52.329 [DEBUG] [org.gradle.internal.nativeintegration.services.NativeServices] Native-platform posix files is not available.  Continuing with fallback.
09:44:52.970 [INFO] [org.gradle.BuildLogger] Starting Build
09:44:52.985 [DEBUG] [org.gradle.BuildLogger] Gradle user home: C:\Users\admin\.gradle
09:44:52.985 [DEBUG] [org.gradle.BuildLogger] Current dir: C:\TCWork\A3\d8fd70f1699db8d9
09:44:52.985 [DEBUG] [org.gradle.BuildLogger] Settings file: null
09:44:53.001 [DEBUG] [org.gradle.BuildLogger] Build file: null
09:44:53.032 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Software Loopback Interface 1
09:44:53.063 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? true
09:44:53.079 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.095 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback address /127.0.0.1
09:44:53.126 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback address /0:0:0:0:0:0:0:1
09:44:53.141 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Software Loopback Interface 1
09:44:53.173 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Microsoft Kernel Debug Network Adapter
09:44:53.204 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.220 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.235 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Microsoft Kernel Debug Network Adapter
09:44:53.266 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)
09:44:53.282 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.298 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.313 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /192.168.10.90
09:44:53.345 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /fe80:0:0:0:409f:a09f:fa9d:4558%eth1
09:44:53.360 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote multicast interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)
09:44:53.376 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Teredo Tunneling Pseudo-Interface
09:44:53.391 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.407 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? false
09:44:53.423 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /2001:0:9d38:6ab8:3813:7b9e:c5ab:10dd
09:44:53.438 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /fe80:0:0:0:3813:7b9e:c5ab:10dd%net0
09:44:53.454 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Realtek PCIe GBE Family Controller
09:44:53.470 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.485 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.501 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Realtek PCIe GBE Family Controller
09:44:53.516 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Microsoft ISATAP Adapter
09:44:53.532 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.563 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? false
09:44:53.579 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding remote address /fe80:0:0:0:0:5efe:c0a8:a5a%net1
09:44:53.610 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-WFP Native MAC Layer LightWeight Filter-0000
09:44:53.626 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.657 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.673 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-WFP Native MAC Layer LightWeight Filter-0000
09:44:53.704 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-QoS Packet Scheduler-0000
09:44:53.751 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.766 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.782 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-QoS Packet Scheduler-0000
09:44:53.813 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-WFP 802.3 MAC Layer LightWeight Filter-0000
09:44:53.845 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false
09:44:53.876 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true
09:44:53.907 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Qualcomm Atheros AR8161 PCI-E Gigabit Ethernet Controller (NDIS 6.30)-WFP 802.3 MAC Layer LightWeight Filter-0000
09:44:53.938 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on cp_init class cache for initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' (C:\Users\admin\.gradle\caches\2.12\scripts\init_5nzv86jq87dekjlqjfr85cpmd\cp_init).
09:44:53.970 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
09:44:54.173 [DEBUG] [org.gradle.api.internal.artifacts.mvnsettings.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: C:\Users\admin\.m2\repository
09:44:54.298 [INFO] [org.gradle.api.Script] Init lib: null
09:44:54.313 [ERROR] [org.gradle.BuildExceptionReporter]
09:44:54.345 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
09:44:54.360 [ERROR] [org.gradle.BuildExceptionReporter]
09:44:54.376 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
09:44:54.392 [ERROR] [org.gradle.BuildExceptionReporter] Initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' line: 32
09:44:54.407 [ERROR] [org.gradle.BuildExceptionReporter]
09:44:54.438 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
09:44:54.438 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating initialization script.
09:44:54.470 [ERROR] [org.gradle.BuildExceptionReporter] > Cannot invoke method split() on null object
09:44:54.485 [ERROR] [org.gradle.BuildExceptionReporter]
09:44:54.501 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
09:44:54.517 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.
09:44:54.532 [LIFECYCLE] [org.gradle.BuildResultLogger]
09:44:54.548 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
09:44:54.563 [LIFECYCLE] [org.gradle.BuildResultLogger]
09:44:54.579 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 2.5 secs
09:44:54.595 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on cp_init class cache for initialization script 'C:\dev\TeamCity\BuildAgent3\plugins\gradle-runner\scripts\init.gradle' (C:\Users\admin\.gradle\caches\2.12\scripts\init_5nzv86jq87dekjlqjfr85cpmd\cp_init).
09:44:54.626 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache artifact cache (C:\Users\admin\.gradle\caches\modules-2) was closed 0 times.
09:44:54.642 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 0 resolution results binary files in 0.0 secs
09:44:54.657 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 0, cache instances: 0, modules served from cache: 0, artifacts: 0
09:44:54.673 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (C:\Users\admin\.gradle\caches\2.12\plugin-resolution) was closed 0 times.

-------------------------------------------------

Running our gradle build without the teamcity init.gradle

This shows our regular build works as expected.

C:\TCWork\A3\d8fd70f1699db8d9> C:\TCWork\A3\d8fd70f1699db8d9\gradlew.bat  clean buildServerCapsule
----------------------------
<snip>

BUILD SUCCESSFUL

Total time: 5 mins 57.522 secs

C:\TCWork\A3\d8fd70f1699db8d9>


Cheers
Oliver

0

Hello Oliver,

The error message "Cannot invoke method split() on null object" is indeed caused by missing TEAMCITY_BUILD_INIT_PATH environment variable. The variable is set by TeamCity Gradle build step.

As to original errors "The system cannot find the file specified" and "Access is denied". TeamCity should do it's best and try handle them. I have opened the issue in YouTrack: https://youtrack.jetbrains.com/issue/TW-45774 please vote for it.

Please, enable debug and stacktrace options. Looks like you are running several build agents on the same machine, so please check if error appears when there are multiple Gradle builds running. If this is the case, disabling Gradle daemon (additional gradle command line parameter: --no-daemon) may help

0

Please sign in to leave a comment.