简体   繁体   中英

Jenkins declarative pipeline create custom workspace for parallel builds

I'm building a project with declarative pipelines, I want to create two different workspaces with two different names for the parallel step. How do I do it?

ie, something like this

build1 workspace : /some/path/build-1
build2 workspace : /some/path/build-2

Are you looking for something like:

pipeline {
    agent none
    stages {
        stage('Parallel Stages') {
            parallel {
                stage('Parallel Stage 1') {
                    agent {
                        node {
                            label 'label'
                            customWorkspace '/tmp/dir1'
                        }
                    }
                    steps {
                        echo pwd()
                    }
                }
                stage('Parallel Stage 2') {
                    agent {
                        node {
                            label 'label'
                            customWorkspace '/tmp/dir2'
                        }
                    }
                    steps {
                        echo pwd()
                    }
                }
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM