[JIRA] (JENKINS-40337) Support custom checkout scm behaviors

2 views
Skip to first unread message

lglickfield@circleup.com (JIRA)

unread,
Dec 9, 2016, 9:20:02 AM12/9/16
to jenkinsc...@googlegroups.com
Logan Glickfield created an issue
 
Jenkins / Improvement JENKINS-40337
Support custom checkout scm behaviors
Issue Type: Improvement Improvement
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2016/Dec/09 2:19 PM
Priority: Minor Minor
Reporter: Logan Glickfield

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!

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 4:23:02 PM12/12/16
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Improvement JENKINS-40337
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 4:24:01 PM12/12/16
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Improvement JENKINS-40337
 
Re: Support custom checkout scm behaviors

Good question - thinking about that now.

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 4:59:01 PM12/12/16
to jenkinsc...@googlegroups.com

How would you feel about a top-level "skipCheckout" (or something like that) option? Then you could do a customized checkout yourself at the beginning of your first stage. I'm as of yet unable to come up with a smooth way to allow specifying the various custom SCM options with validation at the top-level, so I think for now, I'd definitely lean towards a skip option, since that's simpler and I think can be useful in some other ways.

lglickfield@circleup.com (JIRA)

unread,
Dec 12, 2016, 5:01:01 PM12/12/16
to jenkinsc...@googlegroups.com

That sounds like a reasonable solution to me!

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 5:48:02 PM12/12/16
to jenkinsc...@googlegroups.com

Great! I'm going to add a top-level options section and a skipCheckout flag inside that section, so that we don't end up with tons of future flags. =)

mneale@cloudbees.com (JIRA)

unread,
Dec 12, 2016, 6:10:02 PM12/12/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 7:03:01 PM12/12/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 12, 2016, 7:03:02 PM12/12/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 14, 2016, 2:43:01 PM12/14/16
to jenkinsc...@googlegroups.com
 
Re: Support custom checkout scm behaviors

New PR up with a new implementation that moves properties into options as well, so as to avoid confusion about what goes where. https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/70

scm_issue_link@java.net (JIRA)

unread,
Dec 19, 2016, 9:02:03 AM12/19/16
to jenkinsc...@googlegroups.com

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/SkipCheckout.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/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/4a26576c6c406abf3d3979e9bfa28c546ce0f239
Log:
JENKINS-40337 Add Declarative-specific options.

Specifically adding skipCheckout, but also renamed "properties"
section to "options" and put both JobPropertys and DeclarativeOptions
in that section. Yes, we just renamed "jobProperties" to "properties",
but I prefer "options" when we're not just straight-up containing
JobPropertys. So. Yeah.

scm_issue_link@java.net (JIRA)

unread,
Dec 19, 2016, 9:02:05 AM12/19/16
to jenkinsc...@googlegroups.com

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

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 9:03:03 AM12/19/16
to jenkinsc...@googlegroups.com
 

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
        ...
      }
    }
    ...
  }
}
Change By: Andrew Bayer
Status: In Review Resolved
Resolution: Fixed

mneale@cloudbees.com (JIRA)

unread,
Dec 20, 2016, 2:12:01 AM12/20/16
to jenkinsc...@googlegroups.com

p.leibiger@codecraft.de (JIRA)

unread,
Mar 8, 2017, 8:20:02 AM3/8/17
to jenkinsc...@googlegroups.com

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?

This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

p.leibiger@codecraft.de (JIRA)

unread,
Mar 11, 2017, 8:12:02 AM3/11/17
to jenkinsc...@googlegroups.com

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

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:38 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages