我一直在尝试定义一个 Jenkins 管道,它将两个项目从 Github 检出到同一工作区的两个单独的子目录中,但不幸的是,到目前为止我的所有尝试都无济于事。
我找到了一些对某些人有用的例子,并尝试效仿他们。 我用过的在这里:
使用 Jenkins 管道将多个 git 存储库检出到同一个作业中
这里:
下面是我的完整管道脚本,其中包含我试图开始工作的两个结帐变体(dir + git 目前已被注释掉)。
结果总是相同的,第一个项目检查指定的子目录没有问题,然后在尝试检查另一个项目时创建另一个子目录,但我得到“避免第二次获取”。
结账功能在 Mac 和 Linux 上都不起作用。我使用的是 Jenkins 2.277.3
也许对于新人来说,里面有一些明显的东西?无论如何,我会感谢任何有建设性的建议。
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: '[email protected]:mygithubaccount/my-flutter-test-subject.git'
// }
//
// dir (api_client_dir) {
// git credentialsId: 'github_credentials_kh', url: '[email protected]: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: '[email protected]: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: '[email protected]:mygithubaccount/my-scala-rest-client.git'
]]
])
}
}
}
}
我能够使用 GitSCM 插件中的 noTags:False 选项解决签出特定分支的问题。
checkout(
[
$class: 'GitSCM',
branches: [[name: '${jenkins_branch}']],
extensions: [[$class: 'CloneOption', timeout: 20, noTags: false]],
userRemoteConfigs: [[url: '${jenkins_repo}']]
]
)
在您的特定情况下,您需要用 dir(){} 包围结账
dir ('folder1'){
checkout(
//checkout options as above
)
}
dir ('folder2'){
checkout(
//checkout options as above
)
}
希望能帮助解决您的问题。