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

Support custom checkout scm behaviors

    XMLWordPrintable

    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
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            SYNTAX.md
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperties.java
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperty.java
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTOption.java
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTOptions.java
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java
            pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
            pipeline-model-api/src/main/resources/ast-schema.json
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/JobProperties.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/MethodsToList.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Options.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/PropertyOptionContainer.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/DeclarativeOption.java
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/DeclarativeOptionDescriptor.java
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/SkipDefaultCheckout.java
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTranslator.groovy
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/SkipDefaultCheckout/help.jelly
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/JobPropertiesTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTest.java
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/blockInJobProperties.groovy
            pipeline-model-definition/src/test/resources/errors/emptyJobProperties.groovy
            pipeline-model-definition/src/test/resources/errors/invalidPropertiesType.groovy
            pipeline-model-definition/src/test/resources/json/errors/emptyJobProperties.json
            pipeline-model-definition/src/test/resources/json/simpleJobProperties.json
            pipeline-model-definition/src/test/resources/multipleProperties.groovy
            pipeline-model-definition/src/test/resources/simpleJobProperties.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/01ba61a99d1f99bf82ba70d8c94d2d6c5e88714b
            Log:
            Merge pull request #70 from abayer/jenkins-40337-mk2

            JENKINS-40337 Add Declarative-specific options.

            Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/f155b96037e7...01ba61a99d1f

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: SYNTAX.md pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperties.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperty.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTOption.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTOptions.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java pipeline-model-api/src/main/resources/ast-schema.json pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/JobProperties.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/MethodsToList.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Options.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/PropertyOptionContainer.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/DeclarativeOption.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/DeclarativeOptionDescriptor.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/SkipDefaultCheckout.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTranslator.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/SkipDefaultCheckout/help.jelly pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/JobPropertiesTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/OptionsTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/blockInJobProperties.groovy pipeline-model-definition/src/test/resources/errors/emptyJobProperties.groovy pipeline-model-definition/src/test/resources/errors/invalidPropertiesType.groovy pipeline-model-definition/src/test/resources/json/errors/emptyJobProperties.json pipeline-model-definition/src/test/resources/json/simpleJobProperties.json pipeline-model-definition/src/test/resources/multipleProperties.groovy pipeline-model-definition/src/test/resources/simpleJobProperties.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/01ba61a99d1f99bf82ba70d8c94d2d6c5e88714b Log: Merge pull request #70 from abayer/jenkins-40337-mk2 JENKINS-40337 Add Declarative-specific options. Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/f155b96037e7...01ba61a99d1f
            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.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: