Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58554

Workflow parse exception with new approach for unstable stages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • pipeline
    • None
    • Jenkins 2.176.1

      I am following https://jenkins.io/blog/2019/07/05/jenkins-pipeline-stage-result-visualization-improvements/ blogpost to use the new try/catch approach:

      stages {
              stage ('Tests: EN'){
                steps{
                  try {
                    sh 'HOME=$(pwd) bundle && HOME=$(pwd) LOCALE=en BROWSER=chrome-headless-nogpu cucumber --format json --out reports/en.json'
                  }
                  catch (ex) {
                    unstable('Tests failed!')
                  }
                }
              } 

      for marking the results unstable but I'm getting:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 21: Expected a step @ line 21, column 13.
                     try {
                     ^
      
      WorkflowScript: 32: Expected a step @ line 32, column 13.
                     try{
                     ^
      
      WorkflowScript: 43: Expected a step @ line 43, column 13.
                     try{
                     ^
      
      3 errors
      
      	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: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:522)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:320)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Finished: FAILURE
      

      Jenkins versions and plugin versions are all up to date as in the post.

            Unassigned Unassigned
            warden Radek Antoniuk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: