Poll scm in specific branch only

296 views
Skip to first unread message

Den

unread,
May 5, 2020, 9:15:20 AM5/5/20
to Jenkins Users
Hello,

I have a pipeline which should only build if there are changes in branch specified. It builds however every 5 minutes, since there are changes in master. Is there a way to poll scm only for a branch?

Den

pipeline {
    agent none
    triggers {
        pollSCM('H/5 * * * *')
    }
    stages {
        stage ('SCM Pull') {
            agent any
            steps {
                git branch: "mybranch", url: "$URL"
            }
        }
    ...

Aryo Kusumo

unread,
May 5, 2020, 11:11:13 AM5/5/20
to jenkins...@googlegroups.com
Maybe you could try this. It's works for me.

checkout([$class: 'GitSCM', branches: [[name: '$branch_name']], extensions: [[$class: 'WipeWorkspace'], url: '$git_url']]])

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/74e2a3e0-75c3-46bd-b6ed-d1d461398774%40googlegroups.com.

Den

unread,
May 6, 2020, 6:18:28 AM5/6/20
to Jenkins Users
Tried to remove triggers { pollSCM('H/5 * * * *')  } and use checkout function as you describe, but then it is not triggered if there are changes in the branch.


Am Dienstag, 5. Mai 2020 17:11:13 UTC+2 schrieb Aryo Kusumo:
Maybe you could try this. It's works for me.

checkout([$class: 'GitSCM', branches: [[name: '$branch_name']], extensions: [[$class: 'WipeWorkspace'], url: '$git_url']]])

On Tue, 5 May 2020, 20:15 Den, <denni...@gmail.com> wrote:
Hello,

I have a pipeline which should only build if there are changes in branch specified. It builds however every 5 minutes, since there are changes in master. Is there a way to poll scm only for a branch?

Den

pipeline {
    agent none
    triggers {
        pollSCM('H/5 * * * *')
    }
    stages {
        stage ('SCM Pull') {
            agent any
            steps {
                git branch: "mybranch", url: "$URL"
            }
        }
    ...

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages