2016-11-11 295 views
1

我有一個Jenkins作業加載了一個定義要運行的管道的groovy文件。當我運行這個工作時,它報告一個錯誤 - groovy.lang.MissingPropertyException: No such property: ​ for class: groovy.lang.Binding(下面的堆棧跟蹤)。Jenkins管道作業報告Groovy綁定錯誤

這是昨天工作,莫名其妙地停止工作。我已經搜索了文檔,搜索錯誤並儘可能簡化了工作和常見的常規文件,但目前無法確定問題。

我的問題是,有沒有人看過這個問題,如果是的話,什麼是根casue和解決方案?

流水線作業腳本:

#!groovy 

node 
{ 
    def pipeline = load "CommonPipeline.groovy" 
    pipeline.run() 
} 

CommonPipeline.groovy:

#!groovy 
​ 
def run() 
{ 
    echo "#### THIS WORKS! ####" 
} 

return this 

堆棧跟蹤:

Started by user jenkins 
[Pipeline] node 
Running on Worker in c:\path\to\script\groovy-test 
[Pipeline] { 
[Pipeline] load 
[Pipeline] { (CommonPipeline.groovy) 
[Pipeline] } 
[Pipeline] // load 
[Pipeline] } 
[Pipeline] // node 
[Pipeline] End of Pipeline 
groovy.lang.MissingPropertyException: No such property: ​ 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$4.call(Checker.java:241) 
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238) 
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:28) 
    at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) 
    at Script1.run(Script1.groovy:2) 
    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(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    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$001(SandboxContinuable.java:18) 
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33) 
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.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.access$100(CpsThreadGroup.java:78) 
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236) 
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224) 
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    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(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Finished: FAILURE 

回答

3

愚蠢的錯誤 - 當您的文件擴展名爲.groovy時,不需要「shebang」標題語句#!groovy。我從CommonPipeline.groovy中刪除了這個工作,現在工作正常。我不認爲這會有什麼區別!

奇怪的是,自從昨天停止工作以來,我並沒有改變這一點。我能想到的唯一變化是我安裝的一些Jenkins插件更新...

我會留下這個問題和解決方案,以防其他人遇到此問題。

+1

我已經得到這個問題,但沒有shebang。不知道爲什麼發生。 – Chris

相關問題