Jenkins管道DSL失败

时间:2017-05-29 05:17:34

标签: jenkins groovy jenkins-pipeline

请在我的DSL代码段下面找到。我无法弄清楚我在这里做错了什么。

尝试运行以下内容时出现以下错误

podTemplate(cloud: 'local', label: 'docker-kubectl', containers: [containerTemplate(alwaysPullImage: True, image: 'roshans416/docker-kubectl', name: 'docker-kubectl', privileged: true, ttyEnabled: true, workingDir: '/opt')], name: 'docker-kubectl', volumes: [hostPathVolume(hostPath: '/usr/bin/docker', mountPath: '/usr/bin/docker'), hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock'), secretVolume(mountPath: '/root/.kube', secretName: 'kube-config')]) {
node(label: 'docker-kubectl') {
    stage('check pods'){
        sh 'kubectl get pods -n jenkins'
    }
    stage('check docker version'){
        sh 'docker -v'
   }    
  }
}

我收到以下错误。

*Started by user jenkins
[Pipeline] End of Pipeline
groovy.lang.MissingPropertyException: No such property: True for class: WorkflowScript
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:33)
    at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
    at WorkflowScript.run(WorkflowScript:1)
    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.GeneratedMethodAccessor346.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    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:74)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:165)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.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)
Finished: FAILURE*

非常感谢任何帮助。

此致

Muhammed Roshan

1 个答案:

答案 0 :(得分:2)

你在其中一个T文字中使用大写true,在groovy / java true中用全小写字母书写。即在你写的第一行:

podTemplate(..., containers: [containerTemplate(alwaysPullImage: True, ...)],...]) {

应该是

podTemplate(..., containers: [containerTemplate(alwaysPullImage: true, ...)],...]) {