在Gradle Exec任务中调用gcloud:CreateProcess error = 2,系统找不到指定的文件

时间:2018-12-13 23:12:32

标签: gradle gcloud gradle-task

我已经安装了gcloud CLI,并且此命令在cmd或shell中运行正常:

gcloud compute scp --zone europe-west2-b build/libs/distribution-1.0.jar instance-1:distribution.jar

现在,我想创建一个执行相同任务的Gradle任务。受到我写的answer的启发

task deployGCloud(type: Exec) {
    workingDir "$projectDir"
    // on windows
    commandLine 'gcloud', 'compute', 'scp'
    args "--zone europe-west2-b"
    args 'build/libs/distribution-1.0.jar'
    args 'instance-1:distribution.jar'
}
deployGCloud.dependsOn bootJar

但是该任务失败并出现以下错误:

> Task :deployGCloud FAILED    
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':deployGCloud'.
> A problem occurred starting process 'command 'gcloud''

CreateProcess error=2, The system cannot find the file specified

请给我一些有关如何解决它的建议。

0 个答案:

没有答案