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

Support custom checkout scm behaviors

    Details

    • Similar Issues:

      Description

      As I understand it right now, if I specify an agent, it creates a node, runs checkout scm, and uses the same node/workspace for all of the stages? And if I specify agent: none, I have to create my own node in each stage, and re-run checkout scm for each stage?

      What I want to do is specify "Additional Behaviors" on the checkout step (currently using the workaround described here), but achieve the benefits of running it once on the top-level agent and re-using across all stages.

      Is there any way to achieve this? Either by specifying Additional Behaviors on the top-level pipeline, or allowing a user to override the implicit checkout scm that happens when agent is set?

      Thanks!

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            And this is merged - starting with the 0.8 release (hopefully next week!), you'll be able to do:

            pipeline {
              agent any
            
              options {
                skipDefaultCheckout true
              }
            
              stages {
                stage('foo') {
                  steps {
                    checkout //with complicated stuff etc
                    ...
                  }
                }
                ...
              }
            }
            
            Show
            abayer Andrew Bayer added a comment - And this is merged - starting with the 0.8 release (hopefully next week!), you'll be able to do: pipeline { agent any options { skipDefaultCheckout true } stages { stage( 'foo' ) { steps { checkout //with complicated stuff etc ... } } ... } }
            Hide
            michaelneale Michael Neale added a comment -

            nice

            Show
            michaelneale Michael Neale added a comment - nice
            Hide
            pleibiger Peter Leibiger added a comment -

            With skipDefaultCheckout I am able to use something like this.

            stage('Checkout') {
              steps {
                checkout([
                    $class: 'GitSCM',
                    branches: scm.branches,
                    extensions: scm.extensions + [[$class: 'LocalBranch'], [$class: 'CleanCheckout']],
                    userRemoteConfigs: scm.userRemoteConfigs
                ])
              }
            }
            

            This is ugly and requires quite some script approvals. It should be a lot easier, adding SCMExtensions in particular. This should be configurable via options. Is there an issue to track something like this?

            Show
            pleibiger Peter Leibiger added a comment - With skipDefaultCheckout  I am able to use something like this. stage( 'Checkout' ) { steps { checkout([ $class: 'GitSCM' , branches: scm.branches, extensions: scm.extensions + [[$class: 'LocalBranch' ], [$class: 'CleanCheckout' ]], userRemoteConfigs: scm.userRemoteConfigs ]) } } This is ugly and requires quite some script approvals. It should be a lot easier, adding SCMExtensions in particular. This should be configurable via options . Is there an issue to track something like this?
            Hide
            pleibiger Peter Leibiger added a comment -

            Andrew Bayer What do you think regarding my previous comment, are there plans or should I add an issue for this.

            Show
            pleibiger Peter Leibiger added a comment - Andrew Bayer  What do you think regarding my previous comment, are there plans or should I add an issue for this.
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

            Show
            bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                lsglick Logan Glickfield
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: