即使使用完全相同的参数运行,我的构建也会随机工作并随机挂起。在执行复制任务后,它总是卡住了(某些部分被替换了)
task createDocker(group: '<placeholder>', type: Docker) {
push = true
dockerfile = file(stageDir.getAbsolutePath()+"/Dockerfile")
project.group = "<placeholder>"
applicationName = "<placeholder>-clusterservice"
tagVersion = "${project.version}"
doFirst {
println ("Copying Dockerfile to staging area:" + stageDir.getAbsolutePath())
copy {
from "${project.projectDir}/src/main/docker/"
include "**/*"
into stageDir
}
println ("Getting artifact")
copy {
from "$distDir/${war.baseName}-${war.version}.war"
rename "${war.baseName}-${war.version}.war", "clusterservice.war"
into stageDir
}
}
}
我用调试标志运行了它,这是它工作时的样子:
[16:26:15] : [Step 1/1] 16:25:49.730 [QUIET] [system.out] Getting artifact
[16:26:15] : [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute doFirst {} action for :clusterservice:createDocker'
[16:26:15] : [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute doFirst {} action for :clusterservice:createDocker' completed
[16:26:15] : [Step 1/1] 16:25:50.041 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute build for :clusterservice:createDocker' started
[16:26:15] : [Step 1/1] 16:25:50.041 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Setting up staging directory.
[16:26:15] : [Step 1/1] 16:25:50.041 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Creating Dockerfile from file /opt/teamcity/agent/work/7fe8da50bfc4c49f/clusterservice/build-gradle/docker/Dockerfile.
[16:26:15] : [Step 1/1] 16:25:50.045 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Determining image tag: <placeholder>/<placeholder>-clusterservice:8.23.0-SNAPSHOT
[16:26:15] : [Step 1/1] 16:25:50.045 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Using the native docker binary.
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] Sending build context to Docker daemon 194MB
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] Step 1/33 : FROM <placeholder>/tomcat-openjre8:8.5.40
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] ---> aa259d3bf785
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] Step 2/33 : LABEL MAINTAINER 'dev@<placeholder>.com'
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] ---> Using cache
[16:26:15] : [Step 1/1] 16:26:05.213 [QUIET] [system.out] ---> 14bff4363c7f
...
然后它将继续正常构建而不会出错!
这是在完全相同的机器和完全相同的参数上运行的构建失败
[15:53:03] : [Step 1/1] 15:52:37.030 [QUIET] [system.out] Getting artifact
[15:53:03] : [Step 1/1] 15:52:38.608 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute doFirst {} action for :clusterservice:createDocker'
[15:53:03] : [Step 1/1] 15:52:38.609 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute doFirst {} action for :clusterservice:createDocker' completed
[15:53:03] : [Step 1/1] 15:52:38.609 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute build for :clusterservice:createDocker' started
[15:53:03] : [Step 1/1] 15:52:38.609 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Setting up staging directory.
[15:53:03] : [Step 1/1] 15:52:38.612 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Creating Dockerfile from file /opt/teamcity/agent/work/7fe8da50bfc4c49f/clusterservice/build-gradle/docker/Dockerfile.
[15:53:03] : [Step 1/1] 15:52:38.645 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Determining image tag: <placeholder>/<placeholder>-clusterservice:8.23.0-SNAPSHOT
[15:53:03] : [Step 1/1] 15:52:38.645 [INFO] [se.transmode.gradle.plugins.docker.DockerTask] Using the native docker binary.
[15:53:03] : [Step 1/1] 15:53:03.859 [LIFECYCLE] [org.gradle.process.internal.health.memory.MemoryManager]
[15:53:03] : [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 33737138176, Free: 26021330944}
[15:53:03] : [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 33737138176, Free: 26021330944}
[15:53:03] : [Step 1/1] 15:53:03.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1908932608, Committed: 1186463744}
[15:53:08] : [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 33737138176, Free: 26022682624}
[15:53:08] : [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 33737138176, Free: 26022682624}
[15:53:08] : [Step 1/1] 15:53:08.859 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 1908932608, Committed: 1186463744}
[15:53:11] : [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
[15:53:11] : [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
[15:53:11] : [Step 1/1] 15:53:11.450 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
...
它不会出错,并且运行状况检查会重复并无限期运行(我让它运行2个小时以上),并且它只是继续挂起而没有任何错误。我不知道这是怎么回事,如果我手动运行命令,则构建运行完全正常。如果可行,构建大约需要7分钟左右。请帮忙。
答案 0 :(得分:0)
这个特定 docker gradle 插件的项目开发似乎已被放弃。
如果您在此处 https://github.com/Transmode/gradle-docker/issues/119 和此处 https://github.com/Transmode/gradle-docker/issues/37 上查看此 github 页面上的问题,您会看到此问题是多年前报告的,但从未合并过任何修复程序。
还有其他可用的 gradle docker 插件,您可以使用它们在开发中更加活跃。想到了这个https://github.com/bmuschko/gradle-docker-plugin。
我个人在对这一切感到非常厌烦之后,我只是在 bash 脚本中重写了所有内容,并使用 gradle 调用所述脚本以进行必要的 docker 配置。