Reputation: 75
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:
Upvotes: 1
Views: 3069
Reputation: 395
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"
}
}
}
}
}
Upvotes: 5