[JIRA] (JENKINS-58554) Workflow parse exception with new approach for unstable stages

6 views
Skip to first unread message

radek.antoniuk@quiddia.com (JIRA)

unread,
Jul 18, 2019, 10:10:09 AM7/18/19
to jenkinsc...@googlegroups.com
Radek Antoniuk created an issue
 
Jenkins / Bug JENKINS-58554
Workflow parse exception with new approach for unstable stages
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2019-07-18 14:09
Environment: Jenkins 2.176.1
Priority: Minor Minor
Reporter: Radek Antoniuk

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

radek.antoniuk@quiddia.com (JIRA)

unread,
Jul 18, 2019, 10:11:01 AM7/18/19
to jenkinsc...@googlegroups.com
Radek Antoniuk commented on Bug JENKINS-58554
 
Re: Workflow parse exception with new approach for unstable stages

Devin Nusbaum any if I'm doing anything wrong in the Declarative definition?

dnusbaum@cloudbees.com (JIRA)

unread,
Jul 18, 2019, 10:16:02 AM7/18/19
to jenkinsc...@googlegroups.com

Radek Antoniuk try/catch is raw Groovy, you cannot use it in Declarative outside of a script block. Use the warnError or catchError step instead of unstable, as in the first example here:

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

I will try to update the blog post to explicitly mention that the try/catch example only applies for scripted Pipelines.

dnusbaum@cloudbees.com (JIRA)

unread,
Jul 18, 2019, 10:16:03 AM7/18/19
to jenkinsc...@googlegroups.com
Devin Nusbaum closed an issue as Not A Defect
 
Change By: Devin Nusbaum
Status: Open Closed
Resolution: Not A Defect

radek.antoniuk@quiddia.com (JIRA)

unread,
Jul 18, 2019, 10:20:02 AM7/18/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages