Jenkins Groovy unix脚本错误java.lang.NoSuchMethodError:'布尔值可能是位置参数构造函数变量表达式

2w3rbyxf  于 2022-11-21  发布在  Jenkins
关注(0)|答案(1)|浏览(413)

我尝试创建Jenkins管道,并在同一Jenkins示例中从现有工作管道复制了下面的行。

script {
                def GitDValue = sh (
                    script: "pwd",
                    returnStdout: true
                 ).trim()
                echo "GitDirectory: ${GitDValue}"
            }

为了简单起见,我在这个问题中用pwd替换了实际的shell脚本命令。即使pwd也失败了。我还按照下面的文章设置了我的管道https://levelup.gitconnected.com/how-to-create-an-automatic-ecs-deployment-with-jenkins-84c0e83e7cd0
有趣的是,上面的代码在我的本地jenkins示例中没有失败,它只在服务器中失败。
异常堆栈跟踪如下。
任何帮助都是感激不尽的。

java.lang.NoSuchMethodError: 'boolean org.kohsuke.groovy.sandbox.SandboxTransformer.mightBePositionalArgumentConstructor(org.codehaus.groovy.ast.expr.VariableExpression)'
at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitAssignmentOrCast(SandboxCpsTransformer.java:93)
at com.cloudbees.groovy.cps.CpsTransformer$42.run(CpsTransformer.java:1171)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitDeclarationExpression(CpsTransformer.java:1164)
at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:89)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visitExpressionStatement(CpsTransformer.java:589)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$5.run(CpsTransformer.java:515)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitBlockStatement(CpsTransformer.java:512)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer$2.run(CpsTransformer.java:388)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitWithSafepoint(CpsTransformer.java:374)
at com.cloudbees.groovy.cps.CpsTransformer$27.run(CpsTransformer.java:932)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitClosureExpression(CpsTransformer.java:898)
at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:49)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$4.run(CpsTransformer.java:505)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitMethodCallExpression(CpsTransformer.java:487)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visitExpressionStatement(CpsTransformer.java:589)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$5.run(CpsTransformer.java:515)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitBlockStatement(CpsTransformer.java:512)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer$2.run(CpsTransformer.java:388)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitWithSafepoint(CpsTransformer.java:374)
at com.cloudbees.groovy.cps.CpsTransformer$27.run(CpsTransformer.java:932)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitClosureExpression(CpsTransformer.java:898)
at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:49)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$18.run(CpsTransformer.java:702)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitStaticMethodCallExpression(CpsTransformer.java:696)
at org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:45)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$19.run(CpsTransformer.java:714)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitConstructorCallExpression(CpsTransformer.java:709)
at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:46)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$29.run(CpsTransformer.java:976)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitListExpression(CpsTransformer.java:973)
at org.codehaus.groovy.ast.expr.ListExpression.visit(ListExpression.java:64)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$19.run(CpsTransformer.java:714)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitConstructorCallExpression(CpsTransformer.java:709)
at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:46)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$19.run(CpsTransformer.java:714)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitConstructorCallExpression(CpsTransformer.java:709)
at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:46)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer$11.run(CpsTransformer.java:597)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitReturnStatement(CpsTransformer.java:594)
at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:49)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$5.run(CpsTransformer.java:515)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitBlockStatement(CpsTransformer.java:512)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer$2.run(CpsTransformer.java:388)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitWithSafepoint(CpsTransformer.java:374)
at com.cloudbees.groovy.cps.CpsTransformer$27.run(CpsTransformer.java:932)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitClosureExpression(CpsTransformer.java:898)
at org.codehaus.groovy.ast.expr.ClosureExpression.visit(ClosureExpression.java:49)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$4.run(CpsTransformer.java:505)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitMethodCallExpression(CpsTransformer.java:487)
at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:70)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visitExpressionStatement(CpsTransformer.java:589)
at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:363)
at com.cloudbees.groovy.cps.CpsTransformer$5.run(CpsTransformer.java:515)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitBlockStatement(CpsTransformer.java:512)
at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
at com.cloudbees.groovy.cps.CpsTransformer.visit(CpsTransformer.java:357)
at com.cloudbees.groovy.cps.CpsTransformer$2.run(CpsTransformer.java:388)
at com.cloudbees.groovy.cps.CpsTransformer.makeChildren(CpsTransformer.java:446)
at com.cloudbees.groovy.cps.CpsTransformer.makeNode(CpsTransformer.java:409)
at com.cloudbees.groovy.cps.CpsTransformer.visitWithSafepoint(CpsTransformer.java:374)
at com.cloudbees.groovy.cps.CpsTransformer.visitMethod(CpsTransformer.java:231)
at com.cloudbees.groovy.cps.SandboxCpsTransformer.visitMethod(SandboxCpsTransformer.java:73)
at com.cloudbees.groovy.cps.CpsTransformer.call(CpsTransformer.java:136)
at com.cloudbees.groovy.cps.SandboxCpsTransformer.call(SandboxCpsTransformer.java:29)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1087)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:602)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:579)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:323)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:293)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:677)
at groovy.lang.GroovyShell.parse(GroovyShell.java:689)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:513)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:335)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)

已完成:失败
[更新]我找到了一个解决方法。我将输出发送到文件并从文件中阅读,而不是sh (script, returnStdout)。这要感谢另一个stackoverflow的答案。
现在,当我把它赋给int时,它又失败了。如果我不指定datatype,它就工作得很好。
要执行的操作数据类型int, true

相关问题