我有两个存储库,其中一个存储库克隆在另一个 Jenkinsfile 中。 例如,假设我们有两个存储库,其中一个称为 child
子詹金斯文件:
pipeline {
agent any
environment {
repo_credentials_id = 'XXXXXXXXXXXXXXXXXXXXXXXX'
}
stages {
stage ('Hello Worl') {
steps {
echo "Hello World"
}
}
stage ('clone') {
steps {
checkout scm: [$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[credentialsId: repo_credentials_id,url: 'http://example.com/test/test/_git/parent']]]
}
}
}
}
其他存储库是其 Jenkinsfile 的父存储库,就像 Hello world 一样简单
父 Jenkins 文件:
pipeline {
agent any
stages {
stage ('Hello Worl') {
steps {
echo "Hello World"
}
}
}
}
我使用 Azure DevOps 作为 git 源代码控制,使用 Jenkins 作为 CI。 为了将 Azure DevOps 与 Jenkins 集成,我在 Azure DevOps 中使用服务挂钩并像 this 那样配置它。在其配置中,我使用“git trigger build”作为 Azure DevOps 中 Jenkins 服务挂钩中的触发器。 当我在父存储库中创建拉取请求时,除了父作业之外,子作业也会在 Jenkins 中执行。如何在不构建子作业的情况下更新存储库或在父存储库中创建拉取请求?
请在结帐步骤中禁用子模块配置后尝试一下。
checkout scm: [$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
userRemoteConfigs: [[credentialsId: repo_credentials_id,url: 'http://example.com/test/test/_git/parent']]]