如何在Jenkinsfile中禁用特定 checkout 的轮询SCM?

nc1teljy  于 2023-08-03  发布在  Jenkins
关注(0)|答案(1)|浏览(102)

我有两个仓库,其中一个被克隆到另一个Jenkinsfile中。例如,假设我们有两个存储库,其中一个称为子存储库
子Jenkinsfile:

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
父Jenkinsfile:

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服务钩子中的触发器。当我在parent的repository中创建一个pull request时,除了parent job之外,子job也会在Jenkins中执行。如何在父仓库中更新仓库或创建拉取请求而不构建子仓库的作业?

sz81bmfz

sz81bmfz1#

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

checkout scm: [$class: 'GitSCM', 
               branches: [[name: '*/master']],
               doGenerateSubmoduleConfigurations: false, 
               userRemoteConfigs: [[credentialsId: repo_credentials_id,url: 'http://example.com/test/test/_git/parent']]]

字符串

相关问题