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

Allow custom workspaces in declarative pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The declarative pipeline syntax does not appear to allow for custom workspace roots.

      Can this configuration be added to either the agent or options blocks?

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/AbstractDockerAgent.java
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
            pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/WorkspaceDir.java
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/AbstractDockerPipelineScript.groovy
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
            pipeline-model-definition/src/test/resources/inCustomWorkspace.groovy
            pipeline-model-definition/src/test/resources/inCustomWorkspaceInStage.groovy
            pipeline-model-definition/src/test/resources/inWorkspace.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bd2b9a673f0f40708d714adf46a21e4f032ad790
            Log:
            [FIXED JENKINS-41118] Rewrote to make it an agent option

            Needed because we need SCM checkout to happen after the ws() call,
            while with the initial implementation, SCM checkout happened before
            the ws() call. As a bonus, we now can do this for any agent building
            off of Label, so that's nice!

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/AbstractDockerAgent.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/options/impl/WorkspaceDir.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/AbstractDockerPipelineScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java pipeline-model-definition/src/test/resources/inCustomWorkspace.groovy pipeline-model-definition/src/test/resources/inCustomWorkspaceInStage.groovy pipeline-model-definition/src/test/resources/inWorkspace.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bd2b9a673f0f40708d714adf46a21e4f032ad790 Log: [FIXED JENKINS-41118] Rewrote to make it an agent option Needed because we need SCM checkout to happen after the ws() call, while with the initial implementation, SCM checkout happened before the ws() call. As a bonus, we now can do this for any agent building off of Label, so that's nice!
            Hide
            dantran dan tran added a comment -

            is there a official doc/howto/sample for this feature?

            Show
            dantran dan tran added a comment - is there a official doc/howto/sample for this feature?
            Hide
            abayer Andrew Bayer added a comment -

            There will be once https://github.com/jenkins-infra/jenkins.io/pull/715 gets merged. =)

            Show
            abayer Andrew Bayer added a comment - There will be once https://github.com/jenkins-infra/jenkins.io/pull/715  gets merged. =)
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            content/doc/book/pipeline/syntax.adoc
            http://jenkins-ci.org/commit/jenkins.io/57344406ba57e861ae0edc0f6deecb977c7dd06c
            Log:
            JENKINS-41118 - add customWorkspace docs

            Also adding `node` `agent` type (which is just an alias for `label`,
            but hey) and the `reuseNode` option for `docker` and `dockerfile`,
            which we should have added earlier but forgot. Whoops.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: content/doc/book/pipeline/syntax.adoc http://jenkins-ci.org/commit/jenkins.io/57344406ba57e861ae0edc0f6deecb977c7dd06c Log: JENKINS-41118 - add customWorkspace docs Also adding `node` `agent` type (which is just an alias for `label`, but hey) and the `reuseNode` option for `docker` and `dockerfile`, which we should have added earlier but forgot. Whoops.
            Hide
            eckki RJE added a comment -

            This worked for me since version 1.1:

            pipeline {
                agent {
                    label {
                        label ""
                        customWorkspace "C:/work/${BRANCH_NAME}"
                    }
                }
                stages {
                    stage("foo") {
                        steps {
                            echo "Workspace dir is ${pwd()}"
                        }
                    }
                }
            }
            

            Thanks to Andrew Bayer

            Show
            eckki RJE added a comment - This worked for me since version 1.1: pipeline {     agent {         label {             label ""             customWorkspace "C:/work/${BRANCH_NAME}"         }     }     stages {         stage( "foo" ) {             steps {                 echo "Workspace dir is ${pwd()}"             }         }     } } Thanks to Andrew Bayer

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                ssutherland Sean Sutherland
              • Votes:
                3 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: