我为三个github存储库(app1、app2和app3)中的每一个创建了单独的Jenkins作业。然后是部署和测试存储库。
app1回购(启用web钩子) => app1 JenkinsJob app2 repo(启用web钩子) => app2 JenkinsJob app3 repo(启用web钩子) => app3 JenkinsJob部署回购(web钩子未启用)测试回购(web钩子未启用)
下面是app1的jenkinsfile (只有GIT_REPO_URL1与app2 &app3不同)。
pipeline {
environment {
GIT_REPO_URL1 = 'https://github.com/app1.git'
GIT_REPO_URL2 = 'https://github.com/deployment.git'
GIT_REPO_URL3 = 'https://github.com/test.git'
GIT_REPO_AUTH_CRED = 'abcdefg-123123-321123-qwead-asdqwe123'
} agent any
stages {
stage('GitClone1') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/master']], extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: false, reference: '', trackingSubmodules: false]], userRemoteConfigs: [[credentialsId: "${GIT_REPO_AUTH_CRED}", url: "${GIT_REPO_URL1}"]]])
echo '========++++++++ GitClone Completed ========++++++++'
}
}
stage('GitClone2') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/master']], extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: false, reference: '', trackingSubmodules: false]], userRemoteConfigs: [[credentialsId: "${GIT_REPO_AUTH_CRED}", url: "${GIT_REPO_URL2}"]]])
echo '========++++++++ GitClone Completed ========++++++++'
}
}
stage('GitClone3') {
steps {
checkout([$class: 'GitSCM', branches: [[name: 'refs/heads/master']], extensions: [[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: false, reference: '', trackingSubmodules: false]], userRemoteConfigs: [[credentialsId: "${GIT_REPO_AUTH_CRED}", url: "${GIT_REPO_URL3}"]]])
echo '========++++++++ GitClone Completed ========++++++++'
}
}
} }对app1/app2/app3的代码传递分别触发app1/app2/app3Jenkins作业。
现在的问题是,当我将代码更改推到https://github.com/deployment.git或https://github.com/test.git存储库时,会自动触发用于app1、app2和app3的Jenkins管道。
预期修复:应用程序jenkins作业应该只通过向应用程序repos交付代码来触发。
发布于 2022-01-18 09:27:58
我是通过在代码中添加changelog: false和poll: false来获得它的。
下文提供了完整的清单。也许有人会发现这是有益的。
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: "${GIT_CRED}", url: "${GIT_REPO_URL2}"]]]发布于 2022-01-06 16:15:07
GitSCM步骤中的结帐类有一个专用的附加行为,用于禁用配置的存储库的触发器:
不要在提交通知上触发构建 如果选中此存储库,则无论存储库是否匹配,访问通知notifyCommit URL时都将忽略此存储库。
通过使用类IgnoreNotifyCommit的扩展,可以在管道中配置此属性。
因此,要实现您想要的结果,只需将此配置添加到不应该触发作业的每个存储库的checkout选项中。
例如:
checkout([$class: 'GitSCM', branches: [[...]], extensions: [[$class: 'IgnoreNotifyCommit'],[$class: 'SubmoduleOption',...]], userRemoteConfigs: [[...]]])https://stackoverflow.com/questions/70608963
复制相似问题