简体   繁体   English

Jenkins Pipeline:如何避免在存储库上进行轮询

[英]Jenkins Pipeline: how to avoid poll on a repository

I have a Jenkins Pipeline that download source from 3 different repositories. 我有一个Jenkins管道,可以从3个不同的存储库中下载源代码。 One of this has to be downloaded to execute the job but IT HAS NOT to be polled to fire a new build. 必须下载其中之一来执行工作,但是不必轮询它来启动新的构建。

For instance: - REPO A - REPO B - SCRIPTS to Execute 例如:-REPO A-REPO B-要执行的脚本

In the pipeline I checkout all of these and I use the third one (scripts) to execute some scripts inside the pipeline. 在管道中,我签出了所有这些脚本,并使用第三个脚本(脚本)在管道中执行了一些脚本。

I need to checkout all of these but I don't want to let Jenkins poll on the third repo but only on the first two. 我需要检查所有这些,但我不想让詹金斯在第三个存储库上轮询,而仅在前两个存储库上轮询。 At this moment Jenkins fires a new build anytime it finds any change on one of them. 这时,詹金斯(Jenkins)会在发现其中任何一个发生任何更改时随时触发新的构建。 This means that if I change a script Jenkins Starts every projects that include that repo. 这意味着如果我更改脚本,Jenkins将启动包含该存储库的每个项目。

Here is the part of the pipeline that I use to checkout the repos 这是我用来签出仓库的管道部分

stage('Prepare/Checkout') {

        git branch: 'master',
        credentialsId: '***',
        url: 'http://repo.com/repoA.git'

        dir('common') {
            git branch: 'master',
            credentialsId: '***',
            url: 'http://repo.com/repoB.git'
        }

        dir('script') {
            git branch: 'master',
            credentialsId: '****',
            url: 'http://repo.com/scripts.git'
        }


        sh 'mv script/* .'
        load 'env.properties'
    }

Adding screenshot of the simple polling configuration. 添加简单轮询配置的屏幕截图。 This is very similar to mine (I have H/2 instead of */5) Screenshot 这与我的非常相似(我用H / 2代替* / 5) 屏幕截图

Instead of setting polling on Jenkins to check for update you could configure the Web hook that will trigger you job. 无需在Jenkins上设置轮询以检查更新,您可以配置将触发您工作的Web挂钩。 You can have web hooks configured on both the Git repo on code push action. 您可以在代码推送操作的两个Git存储库上都配置Web挂钩。 So, when ever a new code is pushed to repo the web hook will trigger the Jenkins build. 因此,每当有新代码被推送回购时,Web钩子就会触发Jenkins构建。 You can use the following Cloudbees Document that has well detailed explanation on how to configured it. 您可以使用以下Cloudbees文档,其中包含有关如何配置它的详细说明。

https://support.cloudbees.com/hc/en-us/articles/224543927-GitHub-Integration-Webhooks https://support.cloudbees.com/hc/zh-CN/articles/224543927-GitHub-Integration-Webhooks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM