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

scm should allow configuration in the Jenkinsfile

    XMLWordPrintable

Details

    Description

      The GitHub Organization Folder plugin scans an Organization in GitHub and creates jobs for each repository's branches and PRs.

      Because it is automating the creation of so many jobs, it is unreasonable to pre-configure everything needed for checkout scm to work for all cases.

      I propose that we add an easy mechanism to configure the scm object in Jenkinsfile; allowing adding extensions like shallow clone, clean before/after checkout, submodules.

      In JENKINS-37658 jglick said this required an RFE. Using jobDSL isn't useful because all the behavior of GitHub Org Folders cannot be replicated (at least not without lots of glue).

      A workaround is do to something like this:

      checkout(
            [
              $class: 'GitSCM',
              userRemoteConfigs: [[credentialsId: 'github-oauth-userpass', url: 'https://github.com/myorg/myrepository']],
              branches: [[name: '*/$BRANCH_NAME']],
              extensions: [
                [$class: 'AuthorInChangelog'],
                [$class: 'CheckoutOption', timeout: 10],
                [$class: 'CleanBeforeCheckout'],
                [$class: 'CloneOption', depth: 3, honorRefspec: true, noTags: true, reference: '', shallow: true, timeout: 3]
              ]
            ]
          )
      

      This is non-ideal because the user has to know the name of the proper credentials and because they have to hardcode the github repository URL.

      Attachments

        Issue Links

          Activity

            There are no comments yet on this issue.

            People

              Unassigned Unassigned
              docwhat Christian Höltje
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: