[JIRA] (JENKINS-41605) Declarative: agent inside stage does not do automatic checkout scm

2 views
Skip to first unread message

bitwiseman@gmail.com (JIRA)

unread,
Jan 31, 2017, 4:18:01 PM1/31/17
to jenkinsc...@googlegroups.com
Liam Newman created an issue
 
Jenkins / Bug JENKINS-41605
Declarative: agent inside stage does not do automatic checkout scm
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Jan/31 9:17 PM
Priority: Major Major
Reporter: Liam Newman

This pipeline succeeds:

pipeline {
    agent any
    stages {
        stage ('Build') {
            steps {
                sh 'cat Jenkinsfile'
            }
        }
    }
}

This pipeline fails:

pipeline {
    agent any
    stages {
        stage ('Build') {
            agent any
            steps {
                sh 'cat Jenkinsfile'
            }
        }
    }
}

The reason this happens is that the agent inside a stage step does not do checkout scm automatically. This is very confusing behavior. Agent initialization should be consistent whether at top or inside a stage.

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

bitwiseman@gmail.com (JIRA)

unread,
Jan 31, 2017, 4:40:01 PM1/31/17
to jenkinsc...@googlegroups.com
Liam Newman updated an issue
Change By: Liam Newman
This pipeline succeeds:

{code:language=groovy}

pipeline {
    agent any
    stages {
        stage ('Build') {
            steps {
                sh 'cat Jenkinsfile'
            }
        }
    }
}
{code}

This pipeline fails:

{code:language=groovy}

pipeline {
    agent any
    stages {
        stage ('Build') {
            agent any
            steps {
                sh 'cat Jenkinsfile'
            }
        }
    }
}
{code}


The reason this happens is that the agent inside a stage step does not do checkout scm automatically.  This is very confusing behavior.  Agent initialization should be consistent whether at top or inside a stage.


I would expect to do something like this to make an agent in a stage not do checkout:
{code:language=groovy}
pipeline {
    agent any
    options {
        skipDefaultCheckout()

    }
    stages {
        stage ('Build') {
            agent any
            options {
                skipDefaultCheckout()
            }
            steps {
                sh 'cat Jenkinsfile'
            }
        }
    }
}
{code}

andrew.bayer@gmail.com (JIRA)

unread,
Jan 31, 2017, 5:08:03 PM1/31/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-41605
 
Re: Declarative: agent inside stage does not do automatic checkout scm

The reasoning behind automatic checkout only happening at the top level was a conscious decision - and frankly, one I'd still advocate for. But it may make sense to have a per-stage option for "do a fresh checkout of SCM in this stage" - independent of the agent configuration. There've been some other things that have come up that may make sense as part of a stage-level options section.

tyler@monkeypox.org (JIRA)

unread,
Jan 31, 2017, 5:16:01 PM1/31/17
to jenkinsc...@googlegroups.com

Andrew Bayer, why would you still advocate for it? It's wholly inconsistent behavior between stage-level and pipeline-level agent directives.

andrew.bayer@gmail.com (JIRA)

unread,
Feb 14, 2017, 5:07:02 PM2/14/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-41605
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Feb 14, 2017, 5:10:01 PM2/14/17
to jenkinsc...@googlegroups.com

So what I'm leaning towards right now is hooking logic so that the label Declarative agent does always do a checkout (assuming skipDefaultCheckout isn't specified at the top-level, that is) - that'll still avoid doing a redundant checkout when docker or dockerfile are used for an individual stage and reuseNode is specified, since we never actually go through the label Declarative agent then. Implementing now on top of https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/109, which is in the same code (that's JENKINS-41900).

andrew.bayer@gmail.com (JIRA)

unread,
Feb 14, 2017, 5:22:02 PM2/14/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Feb 14, 2017, 5:22:03 PM2/14/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Feb 16, 2017, 1:33:01 PM2/16/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Mar 13, 2017, 6:39:02 PM3/13/17
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-41605
 
Re: Declarative: agent inside stage does not do automatic checkout scm

Code changed in jenkins
User: Andrew Bayer
Path:
content/doc/book/pipeline/syntax.adoc
http://jenkins-ci.org/commit/jenkins.io/dde1b744c20b737ea45cbec3db4335710d2d0c84
Log:
Uncommenting since JENKINS-41605 landed as well.

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

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:40 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