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

Declarative Pipeline does not work with Milestone without Ordinal

    Details

    • Similar Issues:

      Description

      Pipeline milestone step has two optional parameters:

      ordinal number
      label

      stage ("Build") {
      milestone()
      }
      

      works fine in Pipeline script but will fail without an ordinal value in Declarative Pipeline.

      Started by user Admin
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      WorkflowScript: 5: Missing required parameter: 'ordinal' @ line 5, column 13.
      milestone()
      ^

      WorkflowScript: 10: Missing required parameter: 'ordinal' @ line 10, column 13.
      milestone (label: 'Test')
      ^

      WorkflowScript: 15: Missing required parameter: 'ordinal' @ line 15, column 13.
      milestone (label: 'Deploy')
      ^

      3 errors

      at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1073)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546)
      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.reparse(CpsGroovyShell.java:67)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:411)
      at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:374)
      at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:220)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)
      Finished: FAILURE

        Attachments

          Issue Links

            Activity

            Hide
            hrmpw Patrick Wolf added a comment - - edited

            test script that works for Declarative. Remove the ordinal number and it will fail

            pipeline{
                agent none
                stages{
                    stage ("Build"){
                        milestone(1)
                        sleep getTime()
                        echo "finishing build"
                    }
                    stage ("Test"){
                        milestone (10)
                        sleep getTime()
                        echo "finishing Test"
                    }
                    stage ("Deploy"){
                        milestone (20)
                        sleep getTime()
                        echo "finishing Deploy"
                    }
                }
            }
            
            
            
            @NonCPS
            def getTime() {
                if (currentBuild.number % 2 != 0){
                    return 10
                }
                else{
                    return 5
                }
            }
            
            Show
            hrmpw Patrick Wolf added a comment - - edited test script that works for Declarative. Remove the ordinal number and it will fail pipeline{ agent none stages{ stage ( "Build" ){ milestone(1) sleep getTime() echo "finishing build" } stage ( "Test" ){ milestone (10) sleep getTime() echo "finishing Test" } stage ( "Deploy" ){ milestone (20) sleep getTime() echo "finishing Deploy" } } } @NonCPS def getTime() { if (currentBuild.number % 2 != 0){ return 10 } else { return 5 } }
            Hide
            abayer Andrew Bayer added a comment -

            Frankly, I think this isn't a bug - https://github.com/jenkinsci/pipeline-milestone-step-plugin/blob/master/src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStep.java#L62 - the ordinal is a required field. I'm honestly not sure how it works outside declarative without the ordinal! Jesse Glick - is there some magic in DSL that auto-inserts 0 for DataBoundConstructor int parameters that are unspecified?

            Show
            abayer Andrew Bayer added a comment - Frankly, I think this isn't a bug - https://github.com/jenkinsci/pipeline-milestone-step-plugin/blob/master/src/main/java/org/jenkinsci/plugins/pipeline/milestone/MilestoneStep.java#L62 - the ordinal is a required field. I'm honestly not sure how it works outside declarative without the ordinal! Jesse Glick - is there some magic in DSL that auto-inserts 0 for DataBoundConstructor int parameters that are unspecified?
            Hide
            rochdev Roch Devost added a comment -

            As documented here and here it is optional and should be auto-generated if omitted.

            Show
            rochdev Roch Devost added a comment - As documented here  and here  it is optional and should be auto-generated if omitted.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                hrmpw Patrick Wolf
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: