I'm using the Jenkins pipeline plugin with a Jenkinsfile.
In one repository, called vms.git, I have the Jenkinsfile and an application it builds.
I have another repository called deploy.git, which contains scripts I want to use to deploy the application in vms.git.
At the moment my Jenkinsfile just looks like this
node {
stage 'build'
checkout scm
and I am defining the vms.git repo in the job configuration.
So what I would like to do is check out both repositories, then use the Jenkinsfile in vms.git to define the rest of the build. I want to reuse the deploy.git scripts in other pipelines so I don't want to put a Jenkinsfile in there.
You can checkout multiple directories using
checkout
, but you have to specify directory where you want checkout this. You can generate snippets using jenkins (Snippet generator bellow script field). Choose checkout, next git repository and in Additional Behaviours choose: checkout into sub directory.When you will have 2 repositories you can load script from repository you want usin
load
. Example:Another elegant solution for handling multiple Git repositories within single pipeline can be found at this thread.