-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Minor
-
Component/s: pipeline-model-definition-plugin
I have a multibranch pipeline with a Jenkinsfile that contains the following git options :
options {
gitLabConnection('gitlab')
gitlabBuilds(builds: ['Checkout', 'Installation', 'Build', 'Cleanup'])
timestamps()
checkoutToSubdirectory('MyApplicationName')
}
The checkoutToSubDirectory() option has been added early 2018 : JENKINS-44277.
When I create a new branch, the first build fails because the checkout is not performed in the subdirectory mentionned above.
Here are logs for the first commit in a new branch :
Running on tl-node-jenkins in /home/jenkins/workspace/Lab_tp-224-why-does-it-fail-UX4MQZ4M5EQBNID3TXQESLPPCTZG72YJT3JLH5JK74R6J3HSTBMA
[Pipeline] {
[Pipeline] dir
Running in /home/jenkins/workspace/Lab_tp-224-why-does-it-fail-UX4MQZ4M5EQBNID3TXQESLPPCTZG72YJT3JLH5JK74R6J3HSTBMA/MyApplicationName
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Cloning the remote Git repository
Cloning with configured refspecs honoured and without tags
Cloning repository git@gitlab.mycompany.net:sw/MyApplicationName.git
> git init /home/jenkins/workspace/Lab_tp-224-why-does-it-fail-UX4MQZ4M5EQBNID3TXQESLPPCTZG72YJT3JLH5JK74R6J3HSTBMA/MyApplicationName # timeout=10
Fetching upstream changes from git@gitlab.mycompany.net:sw/MyApplicationName.git
> git --version # timeout=10
using GIT_SSH to set credentials Use to clone repositories from Gitlab
> git fetch --no-tags --progress git@gitlab.mycompany.net:sw/MyApplicationName.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url git@gitlab.mycompany.net:sw/MyApplicationName.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url git@gitlab.mycompany.net:sw/MyApplicationName.git # timeout=10
Fetching without tags
Fetching upstream changes from git@gitlab.mycompany.net:sw/MyApplicationName.git
using GIT_SSH to set credentials Use to clone repositories from Gitlab
> git fetch --no-tags --progress git@gitlab.mycompany.net:sw/MyApplicationName.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision 21dd54ff667c95907e96ba9fa0593a740e5e018c (tp-224-why-does-it-fail)
> git config core.sparsecheckout # timeout=10
> git checkout -f 21dd54ff667c95907e96ba9fa0593a740e5e018c
Commit message: "..."
First time build. Skipping changelog.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // dir
[Pipeline] withEnv
[Pipeline] {
[Pipeline] gitlabBuilds
[Pipeline] {
[Pipeline] timestamps
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] gitlabCommitStatus
[Pipeline] {
[Pipeline] checkout
11:05:45 Cloning the remote Git repository
11:05:45 Cloning with configured refspecs honoured and without tags
11:05:45 Cloning repository git@gitlab.mycompany.net:sw/MyApplicationName.git
11:05:45 > git init /home/jenkins/workspace/Lab_tp-224-why-does-it-fail-UX4MQZ4M5EQBNID3TXQESLPPCTZG72YJT3JLH5JK74R6J3HSTBMA # timeout=10
11:05:45 Fetching upstream changes from git@gitlab.mycompany.net:sw/MyApplicationName.git
11:05:45 > git --version # timeout=10
11:05:45 using GIT_SSH to set credentials Use to clone repositories from Gitlab
11:05:45 > git fetch --no-tags --progress git@gitlab.mycompany.net:sw/MyApplicationName.git +refs/heads/*:refs/remotes/origin/*
11:05:48 > git config remote.origin.url git@gitlab.mycompany.net:sw/MyApplicationName.git # timeout=10
11:05:48 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
11:05:48 > git config remote.origin.url git@gitlab.mycompany.net:sw/MyApplicationName.git # timeout=10
11:05:48 Fetching without tags
11:05:48 Fetching upstream changes from git@gitlab.mycompany.net:sw/MyApplicationName.git
11:05:48 using GIT_SSH to set credentials Use to clone repositories from Gitlab
11:05:48 > git fetch --no-tags --progress git@gitlab.mycompany.net:sw/MyApplicationName.git +refs/heads/*:refs/remotes/origin/*
11:05:48 Checking out Revision 21dd54ff667c95907e96ba9fa0593a740e5e018c (tp-224-why-does-it-fail)
11:05:48 > git config core.sparsecheckout # timeout=10
11:05:48 > git checkout -f 21dd54ff667c95907e96ba9fa0593a740e5e018c
11:05:48 Commit message: "..."
The repository is checkout twice, the second time ignoring the subdirectory name provided. This behavior is only exhibited for the first commit in a new branch.