我已按照文章here进行操作,并使用springboot应用程序将其部署到GKE,该作业一直执行到最后一阶段失败,但最终部署到了GKE。
-------------------------------------------------------
omitted for brevity
-----------------------------
Running com.example.TestGreeter
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.101 sec
Results :
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ server ---
[INFO] Building jar: /var/lib/jenkins/workspace/Hello/server/target/server.jar
[INFO]
[INFO] ------------------< com.example.maven-project:webapp >------------------
[INFO] Building Webapp 1.0-SNAPSHOT [3/3]
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ webapp ---
[INFO] Deleting /var/lib/jenkins/workspace/Hello/webapp/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ webapp ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/Hello/webapp/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ webapp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ webapp ---
[debug] execute contextualize
[INFO] Using 'utf-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/Hello/webapp/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompil
+ docker push registry.hub.docker.com/rdocker11/simple-devops-image:latest
The push refers to repository [registry.hub.docker.com/rdocker11/simple-devops-image]
b9725720a38a: Preparing
117a4af1f7d6: Preparing
c9fe82b92442: Preparing
5977227d48fa: Waiting
27974e3533d3: Waiting
d35c5bda4793: Waiting
a3c1026c6bcc: Waiting
f1d420c2af1a: Waiting
461719022993: Waiting
117a4af1f7d6: Layer already exists
34303658eb0e: Layer already exists
c9fe82b92442: Layer already exists
b9725720a38a: Pushed
latest: digest: sha256:a2df4896fd2563ee73ff628d8aeb784947a55fb0bb94415734e1109655d81adc size: 2629
[Pipeline] isUnix
[Pipeline] sh
+ docker tag rdocker11/simple-devops-image:25 registry.hub.docker.com/rdocker11/simple-devops-image:25
[Pipeline] isUnix
[Pipeline] sh
+ docker push registry.hub.docker.com/rdocker11/simple-devops-image:25
The push refers to repository [registry.hub.docker.com/rdocker11/simple-devops-image]
f1d420c2af1a: Preparing
461719022993: Preparing
5977227d48fa: Waiting
27974e3533d3: Waiting
d35c5bda4793: Waiting
a3c1026c6bcc: Waiting
f1d420c2af1a: Waiting
461719022993: Waiting
c9fe82b92442: Layer already exists
117a4af1f7d6: Layer already exists
c46c0b39fa89: Layer already exists
34303658eb0e: Layer already exists
b9725720a38a: Layer already exists
5977227d48fa: Layer already exists
27974e3533d3: Layer already exists
d35c5bda4793: Layer already exists
a3c1026c6bcc: Layer already exists
461719022993: Layer already exists
f1d420c2af1a: Layer already exists
25: digest: sha256:a2df4896fd2563ee73ff628d8aeb784947a55fb0bb94415734e1109655d81adc size: 2629
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy to GKE)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ sed -i s/simple-devops-image:latest/simple-devops-image:25/g deployment.yaml
[Pipeline] step
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Caused: java.io.IOException: Cannot run program "kubectl": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:936)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.Launcher$ProcStarter.join(Launcher.java:465)
at com.google.jenkins.plugins.k8sengine.KubectlWrapper.launchAndJoinCommand(KubectlWrapper.java:166)
at com.google.jenkins.plugins.k8sengine.KubectlWrapper.runKubectlCommand(KubectlWrapper.java:112)
at com.google.jenkins.plugins.k8sengine.KubernetesEngineBuilder.perform(KubernetesEngineBuilder.java:267)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
我已经创建了google服务帐户和集群,并且已经按照jenkins服务器上的google linux安装步骤提供了详细信息,并且已经安装了kubectl。 非常感谢您的帮助。 谢谢,