如何在 Jenkinsfile 中禁用 poll scm 以进行特定结帐?

问题描述 投票:0回答:1

我有两个存储库,其中一个存储库克隆在另一个 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 中执行。如何在不构建子作业的情况下更新存储库或在父存储库中创建拉取请求?

jenkins azure-devops jenkins-pipeline git-submodules git-checkout
1个回答
0
投票

请在结帐步骤中禁用子模块配置后尝试一下。

checkout scm: [$class: 'GitSCM', 
               branches: [[name: '*/master']],
               doGenerateSubmoduleConfigurations: false, 
               userRemoteConfigs: [[credentialsId: repo_credentials_id,url: 'http://example.com/test/test/_git/parent']]]
© www.soinside.com 2019 - 2024. All rights reserved.