简体   繁体   中英

Jenkins Pipeline Checkout SVN to custom workspace

I'm writing an Jenkins Pipeline script at the moment (declarative). Basically like this:

pipeline {
    agent any
    environment {
        NLS_LANG = 'GERMAN_GERMANY.AL32UTF8'
    }
    stages {
        stage('Test') {
            steps {
                script {
                    echo "Test"
                }
            }
        }
    }
}

The script itself works fine. But we now found out, that the jenkins checks out our SVN repository first to find the Jenkinsfile (Checkout in folder workspace@script in the job Folder > C:\\jenkins_home\\jobs\\<Projectname>\\jobs\\<Jobname> ).

Than the whole SVN is checked out again in an second step which I didn't wrote in the Jenkinsfile (Title: " Declarative: SCM Checkout "). It would be okay, if we could change the path of this checkout, because at the moment it checks out in a new created workspace folder in the job folder .

Here I have a screenshot from the console output of the pipeline job: 在此处输入图片说明

How can the checkout in a custom workspace be achieved?

Preferably it would only checkout the Jenkinsfile on it's own on the first checkout, not the whole repository. I tried to change the repository url to the folder where the Jenkinsfile is saved (alone), but than the pipeline is also (only) checking out this folder on the second checkout.

Here I have a screenshot of the console output trying this:

To whom it may concern when coming around this question: use a ws('/path/to/dir') to allocate a different directory (see Pipeline: Nodes and processes )

pipeline {
    agent any
    environment {
        NLS_LANG = 'GERMAN_GERMANY.AL32UTF8'
    }
stages {
    stage('Test') {
        steps {
            script {
                echo "Test"
                ws('/path/to/dir'){
                    //dosomething here, like "checkout scm"
                }
            }
        }
    }
}    

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