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

Promote delegates of metasteps to top-level functions, deprecate $class

XMLWordPrintable

      Currently you must write e.g.

      step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/*.xml'])
      

      which is awkward. Also in Snippet Generator you need to look under General Build Step for what to a user is logically a distinct step.

      Metasteps (step, wrap, checkout) should have an API by which they can declare that their delegate (scm in the last case) ought to be treated as a top-level step as far as DSL and Snippetizer are concerned, via some kind of syntactic sugar. In the absence of any Jenkins core API which would allow a Descriptor to specify a short name (yaml-project tries to define one of its own), this would have to be constructed somehow from the $class, perhaps simply:

      JUnitResultArchiver testResults: 'target/surefire-reports/*.xml'
      

      or with just one mandatory parameter even

      JUnitResultArchiver 'target/surefire-reports/*.xml'
      

      The follow-up question is what to do with nested Describable objects used in the configuration. So

      GitSCM ..., extensions: [[$class: 'PruneStaleBranch']]
      

      still looks unnatural. The Groovy builder idiom might suggest

      GitSCM ..., extensions: [PruneStaleBranch {}]
      

      though closure handling in JENKINS-26135 would need to be addressed first. Requires study to make a PoC.

            kohsuke Kohsuke Kawaguchi
            jglick Jesse Glick
            Votes:
            7 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: