<p>One could use the <a href="https://wiki.jenkins.io/display/JENKINS/PollSCM+Plugin" rel="nofollow noreferrer">PollSCM plugin</a>.</p>

<p><a href="https://jenkins.io/doc/book/pipeline/syntax/" rel="nofollow noreferrer">https://jenkins.io/doc/book/pipeline/syntax/</a></p>

<pre><code>triggers { pollSCM('H 4/* 0 0 1-5') }
</code></pre>

<blockquote>
  <p>The pollSCM trigger is only available in Jenkins 2.22 or later.</p>
</blockquote>

CC BY-SA 3.0
2017-10-20T19:56:33.313Z
2017-10-20T19:56:33.313Z
030
<p>We have a gitlab enterpise that host multiple project in one repo. Something like:</p>

<pre><code>Repo/
  projectA/
  projectB/
  projectC/
</code></pre>

<p>We have three pipelines that will run base on changes(whitelist region) when polling. They will start polling when received a <code>curl</code> via the <code>notifyCommit?</code> in another job.</p>

<p>However, the pipeline can only work on <code>branch</code> that is run previously. </p>

<p>I have also try to use parameters $branch on <code>branch to build</code> and update the <code>curl</code> job with parameters like:</p>

<p><code>http://ourjenkins/git/notifyCommit?url=git_url.git&amp;branch=$GIT_BRANCH</code></p>

<p>but, it still will only poll the last run branch. </p>

<p>Does anyone know how we can have the declarative pipeline to poll multiple branches and run only base on whitelist directory changes?</p>

CC BY-SA 3.0
2017-11-21T18:13:52.377Z
Have you tried using a multibranch pipeline job? See https://jenkins.io/doc/book/pipeline/multibranch/
mghicks
CC BY-SA 4.0
2018-11-16T15:18:20.060Z
Yes, I definitely recommend the multibranch pipeline plugin. You can also filter by branch name if there is a common naming convention.
Preston Martin
<jenkins><continuous-integration><jenkinsfile>
Declarative Jenkins Pipeline to Poll different branches?
Zac Kwan
# Declarative Jenkins Pipeline to Poll different branches?

(Asked by: username_0 on 2017-08-23)

We have a gitlab enterpise that host multiple project in one repo. Something like:
Repo/
  projectA/
  projectB/
  projectC/

We have three pipelines that will run base on changes(whitelist region) when polling. They will start polling when received a curl via the notifyCommit? in another job.
However, the pipeline can only work on branch that is run previously. 
I have also try to use parameters $branch on branch to build and update the curl job with parameters like:
http://ourjenkins/git/notifyCommit?url=git_url.git&branch=$GIT_BRANCH
but, it still will only poll the last run branch. 
Does anyone know how we can have the declarative pipeline to poll multiple branches and run only base on whitelist directory changes?

**Tags:** jenkins, continuous-integration, jenkinsfile

> **Comments:**
> **username_1**: Have you tried using a multibranch pipeline job? See https://jenkins.io/doc/book/pipeline/multibranch/  
> **username_2**: Yes, I definitely recommend the multibranch pipeline plugin. You can also filter by branch name if there is a common naming convention.  

---

## 1 answers

### Answer by username_3 on 2017-10-20. Score: 1

One could use the PollSCM plugin.
https://jenkins.io/doc/book/pipeline/syntax/
triggers { pollSCM('H 4/* 0 0 1-5') }


The pollSCM trigger is only available in Jenkins 2.22 or later.


---

