I've been trying to define a Jenkins pipeline that would checkout two projects from Github into two separate subdirectories of the same workspace, but unfortunately all my attempts so far are to no avail.
I found some examples that have worked for some people and tried to emulate them. They ones I used are here:
Using a Jenkins pipeline to checkout multiple git repos into same job
and here:
Is it impossible to checkout a different branch in Jenkinsfile?
And below is my complete pipeline script with two checkout variants I was trying to get to work (the dir + git is currently commented out).
The outcome is always the same, fist project checks out no problem into the designated subdirectory, then on the attempt to check out the other project the other subdirectory gets created but I get the "Avoid second fetch".
The checkout does not work on neither Mac nor on Linux. I am on Jenkins 2.277.3
Perhaps there is something obvious in there for fresh pair of eyes? Anyways I will appreciate any constructive suggestions.
def api_client_dir = 'scala-api-client'
def subject_dir = 'app-under-test'
pipeline {
agent { label 'Mac' } //Change this to whatever your flutter jenkins nodes are labeled.
stages {
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Checkout') {
steps {
// dir (subject_dir) {
// git credentialsId: 'github_credentials_kh', url: 'git@github.com:mygithubaccount/my-flutter-test-subject.git'
// }
//
// dir (api_client_dir) {
// git credentialsId: 'github_credentials_kh', url: 'git@github.com:mygithubaccount/my-scala-rest-client.git'
// }
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: subject_dir]],
userRemoteConfigs: [[
credentialsId: 'github_credentials_kh',
url: 'git@github.com:mygithubaccount/my-flutter-test-subject.git'
]]
])
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: api_client_dir]],
userRemoteConfigs: [[
credentialsId: 'github_credentials_kh',
url: 'git@github.com:mygithubaccount/my-scala-rest-client.git'
]]
])
}
}
}
}