Jenkins建置時Jenkinsfile中的docker指令無法執行
世界只因有你
世界只因有你 2017-04-25 09:01:44
0
1
1004

使用Docker,Jenkins建置專案的時候,Jenkinsfile中的docker語句執行報如下錯誤:

[Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Create Docker Image) [Pipeline] dir Running in /Users/larry/.jenkins/workspace/docker-jenkins-pipeline/RpcServerSample [Pipeline] { [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224) at org.kohsuke.groovy.sandbox.impl.Checker.call(Checker.java:241) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221) at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:221) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:24) at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:12) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:58) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access
node { checkout scm //env.PATH = "${tool 'Maven3'}/bin:${env.PATH}" stage('Package') { dir('RpcServerSample') { sh 'mvn clean package -DskipTests' } } stage('Create Docker Image') { dir('RpcServerSample') { docker.build("daocloud.io/suqun/docker-jenkins-pipeline:${env.BUILD_NUMBER}") } } stage ('Run Application') { try { // Start database container here // sh 'docker run -d --name db -p 8091-8093:8091-8093 -p 11210:11210 arungupta/oreilly-couchbase:latest' // Run application using Docker image // sh "DB=`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db`" sh "docker run -d -p 9001:9001 daocloud.io/suqun/docker-jenkins-pipeline:${env.BUILD_NUMBER}" // Run tests using Maven //dir ('webapp') { // sh 'mvn exec:java -DskipTests' //} } catch (error) { } finally { // Stop and remove database container here //sh 'docker-compose stop db' //sh 'docker-compose rm db' } } stage('Run Tests') { try { dir('RpcServerSample') { sh "mvn test" docker.build("daocloud.io/suqun/docker-jenkins-pipeline:${env.BUILD_NUMBER}").push() } } catch (error) { } finally { junit '**/target/surefire-reports/*.xml' } } }
1(SandboxContinuable.java:18) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.call(SandboxContinuable.java:33) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.call(SandboxContinuable.java:30) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access0(CpsThreadGroup.java:78) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:236) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.call(CpsThreadGroup.java:224) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.call(CpsVmExecutorService.java:63) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService.run(ContextResettingExecutorService.java:28) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

其中Jenkinsfile內容如下:

rrreee

報錯語句是:docker.build("daocloud.io/suqun/docker-jenkins-pipeline:${env.BUILD_NUMBER}")

猜測是不是groovy的什麼插件沒裝啊?

世界只因有你
世界只因有你

全部回覆 (1)
某草草

問題已解決,缺少Jenkins的插件
在系統管理-->管理插件-->可選插件中搜尋CloudBees Docker Pipeline,直接安裝即可

    最新下載
    更多>
    網站特效
    網站源碼
    網站素材
    前端模板
    關於我們 免責聲明 Sitemap
    PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!