简体   繁体   中英

Jenkins Pipeline: how to avoid poll on a repository

I have a Jenkins Pipeline that download source from 3 different repositories. 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

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. This means that if I change a script Jenkins Starts every projects that include that repo.

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

Instead of setting polling on Jenkins to check for update you could configure the Web hook that will trigger you job. You can have web hooks configured on both the Git repo on code push action. So, when ever a new code is pushed to repo the web hook will trigger the Jenkins build. You can use the following Cloudbees Document that has well detailed explanation on how to configured it.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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