1
votes

I have configured a jenkins multibranch pipeline project and I want to use Jenkinsfile from SCM. The suggested way is to just put a Jenkinsfile into my project. Jenkins will then bootstrap a job by cloning the repo and run the Jenkinsfile. I noted however, that the workspace then contains my project cloned three times: workspace/myproject and workspace/myproject@script, and workspace/myproject@tmp. I'd think that one clone would be sufficient? When I look at the build output, it sais something along:

Started by user felix
Checking out git file:///C:/users/felix/git/myproject.git into C:\Program Files (x86)\Jenkins\workspace\myproject_local-win@script to read Jenkinsfile
// then all the git stuff..
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\myproject_local-win
// then the pipeline

So it clones into @Script to get the Jenkinsfile, and then runs it in a different clone? I can't see this explained anywhere, which makes me feel uncomfortable. So, what's the rationale?

1
The whole thing is sort of a chicken/egg problem. What I now read is that if you use github, it will not actually clone anything to get the Jenkinsfile but download it via github API. - zedoo

1 Answers

1
votes

You need to enable shallow cloning of your branch in order to fetch the Jenkinsfile, and then you can retrieve the whole branch using the regular checkout steps.