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

Add ability SKIP stage in script pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I try to improve visualization for pipeline.

      I want skip stage and mark skip stage as skip.

      But using Skripted Pipeline i must approve signature.

       

      staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils markStageSkippedForConditional java.lang.String

       

      Using it: 

      import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
      map_dev = ["dev", "qa", "stage" ,"perf"]
      
      prodPromoter = null
      
      map_dev.each {
       stage("${it}") {
        try{
         prodPromoter = input(message: "Deploy ${it}")
        } catch(e){
         Utils.markStageSkippedForConditional("${it}")
        }
       }
      }
      

       

       I now that i can using Declarative Pipeline like this:

       

      when {
       expression {
         try {
          devPromoter = input(message: "Deploy")
         } catch(e) {
           return false
         }
        }
       }
       steps { }
      

       BUT, Could you please just add Utils.markStageSkippedForConditional to @whitelist ?

      Because Scripted pipleine more readable and flexible for me... 

       

      Thank you for advance!

        Attachments

          Issue Links

            Activity

            alexandr_semak Alexandr Semak created issue -
            alexandr_semak Alexandr Semak made changes -
            Field Original Value New Value
            Description I try to improve visualization for pipeline.

            I want skip stage and mark skip stage as skip.

            But using Skripted Pipeline i must approve signature.

             
            {code:java}
            staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils markStageSkippedForConditional java.lang.String{code}
             

            Using it: 
            {code:java}
            import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
            map_dev = ["dev", "qa", "stage" ,"perf"]

            prodPromoter = null

            map_dev.each {
             stage("${it}") {
              try{
               prodPromoter = input(message: "Deploy ${it}")
              } catch(e){
               Utils.markStageSkippedForConditional("${it}")
              }
             }
            }
            {code}
             

             I now that i can using Declarative Pipeline like this:

             
            {code:java}
            when {
             expression {
               try {
                devPromoter = input(message: "Deploy")
               } catch(e) {
                 return false
               }
              }
             }
             steps { }
            {code}
             BUT, can you just add Utils.markStageSkippedForConditional to @whitelist ?

            Because Scripted pipleine more readable and flexible for me... 

             

            Thank you for advance!
            I try to improve visualization for pipeline.

            I want skip stage and mark skip stage as skip.

            But using Skripted Pipeline i must approve signature.

             
            {code:java}
            staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils markStageSkippedForConditional java.lang.String{code}
             

            Using it: 
            {code:java}
            import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
            map_dev = ["dev", "qa", "stage" ,"perf"]

            prodPromoter = null

            map_dev.each {
             stage("${it}") {
              try{
               prodPromoter = input(message: "Deploy ${it}")
              } catch(e){
               Utils.markStageSkippedForConditional("${it}")
              }
             }
            }
            {code}
             

             I now that i can using Declarative Pipeline like this:

             
            {code:java}
            when {
             expression {
               try {
                devPromoter = input(message: "Deploy")
               } catch(e) {
                 return false
               }
              }
             }
             steps { }
            {code}
             BUT, Could you please just add Utils.markStageSkippedForConditional to @whitelist ?

            Because Scripted pipleine more readable and flexible for me... 

             

            Thank you for advance!
            alexandr_semak Alexandr Semak made changes -
            Labels Script jekins pipleine Script jenkins pipeline
            abayer Andrew Bayer made changes -
            Component/s pipeline-stage-step-plugin [ 21709 ]
            Component/s pipeline [ 21692 ]
            Hide
            amdokamal S. Panchenko added a comment - - edited

            I do agree with this proposal. In addition to, there is another reason. This should prevent against the error:

            "Scripts not permitted to use staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils markStageSkippedForConditional java.lang.String. Administrators can decide whether to approve or reject this signature.

            For another, this may duplicate JENKINS-37781

            Show
            amdokamal S. Panchenko added a comment - - edited I do agree with this proposal. In addition to, there is another reason. This should prevent against the error: "Scripts not permitted to use staticMethod org.jenkinsci.plugins.pipeline.modeldefinition.Utils markStageSkippedForConditional java.lang.String. Administrators can decide whether to approve or reject this signature. For another, this may duplicate JENKINS-37781
            amdokamal S. Panchenko made changes -
            Link This issue relates to JENKINS-47286 [ JENKINS-47286 ]
            Hide
            gabloe Gabriel Loewen added a comment -

            It would be great to have this feature, or at least whitelist markStageSkippedForConditional so that the method is allowed in groovy sandbox. I am trying to bring my codebase into compliance with groovy script security, but I am finding it incredibly difficult as there are features that I need to support in scripted pipeline that are only supported securely in declarative pipelines, such as markStageSkippedForConditional.

            Show
            gabloe Gabriel Loewen added a comment - It would be great to have this feature, or at least whitelist markStageSkippedForConditional so that the method is allowed in groovy sandbox. I am trying to bring my codebase into compliance with groovy script security, but I am finding it incredibly difficult as there are features that I need to support in scripted pipeline that are only supported securely in declarative pipelines, such as markStageSkippedForConditional.
            v2v Victor Martinez made changes -
            Assignee Victor Martinez [ v2v ]
            v2v Victor Martinez made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            v2v Victor Martinez made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            Show
            v2v Victor Martinez added a comment - PR:  https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/346
            v2v Victor Martinez made changes -
            Remote Link This issue links to "PR (Web Link)" [ 23325 ]

              People

              Assignee:
              v2v Victor Martinez
              Reporter:
              alexandr_semak Alexandr Semak
              Votes:
              6 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated: