小编Cee*_*ird的帖子

Jenkinsfile 管道错误:“预期一步”和“未定义部分”

谁能解释为什么我会收到以下错误,以及可能的解决方案是什么?

在耐久性级别运行:MAX_SURVIVABILITY org.codehaus.groovy.control.MultipleCompilationErrorsException:启动失败:WorkflowScript:43:预期步骤@第 43 行,第 17 列。如果(isUnix()){ ^

WorkflowScript:71:未定义的部分“成功”@第 71 行,第 5 列。成功 { ^

WorkflowScript:78:未定义的部分“失败”@第 78 行,第 5 列。失败 { ^

WorkflowScript:16:工具类型“maven”没有配置“MAVEN_HOME”的安装 - 你的意思是“Maven M2”?@ 第 16 行,第 19 列。maven "MAVEN_HOME" ^

WorkflowScript:17:工具类型“jdk”没有配置“JAVA_HOME”的安装 - 您的意思是“null”吗?@第17行,第17列。jdk“JAVA_HOME”^

中的代码Jenkinsfile如下:

  pipeline {

        // agent defines where the pipeline will run.
        agent {
            // Here we define that we wish to run on the agent with the label SL202_win
            label "SL202_win"
        }

        // The tools directive allows you to automatically install tools …
Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-pipeline

5
推荐指数
1
解决办法
3万
查看次数

如何使用Jenkins插件Pipeline Utility步骤中的readYAML方法在Jenkins管道中解析YAML文件

我正在尝试使用Jenkins插件“ Pipeline Utility Steps”中的readYaml方法来解析Jenkins管道中的YAML文件。

我在论坛上读到,应该在管道的节点块中调用readYml方法。

在修改这个readYml方法之前,我的管道运行完美。

但是在将readYml添加到管道的节点块之后,出现以下错误。


org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 5: Expected to find someKey "someValue" @ line 5, column 14.
           node {
                ^

1 error

    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
    at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:131)
    at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:125)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:560)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:521)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:290)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
Run Code Online (Sandbox Code Playgroud)

我不会对完整的管道代码感到厌烦,因为问题确实出在编辑我的节点块之后。

我将插件称为readYml方法的方式如下。

pipeline {
    agent {
        node {
            label 'lsrv9557.linux.rabobank.nl'
            customWorkspace '/appl/jenkins/workdir'
            datas = readYaml file: "manifest.yml"
        }
   }
Run Code Online (Sandbox Code Playgroud)

如何使它正常工作并摆脱错误?

提前致谢。

groovy jenkins jenkins-plugins jenkins-pipeline

1
推荐指数
1
解决办法
9075
查看次数