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

Implement pathRestriction to job DSL extension context

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      pathRestriction is not implemented in extension GitContext. So when we want to use this we have to use configure block. It is fine if you are not in sandbox mode.

       

      pipelineJob("jobname") {
      //..
          definition {
              cpsScm {
                  scm {
                      git {
                          //..
                          extensions {
                              relativeTargetDirectory("myRootPath") // works because implemented 
                              pathRestriction('includedPaths', 'excludedPaths') // not implemented in the dsl plugin
                          }
                          // code below doesn't allowed in sandbox mode
                          configure { node ->
                              node / 'extensions' / 'hudson.plugins.git.extensions.impl.PathRestriction' {
                                  excludedRegions 'excludedPaths'
                              }
                          }
                      }
                  }
              }
          }
      }
      
      
      

       

      Can't we add pathRestriction to the extensions GitContext.

      Here is how relativeTargetDirectory implemented. 

        Attachments

          Activity

          Hide
          onuralp Onuralp Taner added a comment - - edited

          I've created this PR to implement this. After the merge, we can use it like below.

          pipelineJob("jobname") {
          //..
              definition {
                  cpsScm {
                      scm {
                          git {
                              //..
                              extensions {
                                  pathRestriction {
                                      includedPaths('includedFiles')
                                      excludedPaths('excludedFiles')
                              }
                          }
                      }
                  }
              }
          }
          
          Show
          onuralp Onuralp Taner added a comment - - edited I've created this  PR to implement this. After the merge, we can use it like below. pipelineJob( "jobname" ) { //.. definition { cpsScm { scm { git { //.. extensions { pathRestriction { includedPaths( 'includedFiles' )    excludedPaths( 'excludedFiles' ) } } } } } }
          Hide
          daspilker Daniel Spilker added a comment -

          This is already supported by the Dynamic DSL:

          pipelineJob('example') {
            definition {
              cpsScm {
                scm {
                  git {
                    extensions {
                      pathRestriction {
                        includedRegions('includedFiles')
                        excludedRegions('excludedFiles')
                      }
                    }
                  }
                }
              }
            }
          }
          
          Show
          daspilker Daniel Spilker added a comment - This is already supported by the Dynamic DSL : pipelineJob( 'example' ) { definition { cpsScm { scm { git { extensions { pathRestriction { includedRegions( 'includedFiles' ) excludedRegions( 'excludedFiles' ) } } } } } } }
          Hide
          fairmonk mihai ono added a comment -

          Daniel Spilker can you tell in which version of Job DSL plugin is the  Dynamic DSL available such that excludedRegions() can be used ?

          I checked my http://localhost:8080/plugin/job-dsl/api-viewer/index.html and the method is not there. I got 1.59 plugin version installed and can update only to 1.67

           

          Show
          fairmonk mihai ono added a comment - Daniel Spilker can you tell in which version of  Job DSL plugin  is the   Dynamic DSL  available such that excludedRegions() can be used ? I checked my http://localhost:8080/plugin/job-dsl/api-viewer/index.html  and the method is not there. I got 1.59 plugin version installed and can update only to 1.67  

            People

            • Assignee:
              daspilker Daniel Spilker
              Reporter:
              onuralp Onuralp Taner
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: