# Prevent scan of Multibranch-Pipeline while a build is active

**URL:** <https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642>\
**Category:** Ask a question\
**Created:** [May 26, 2023, 1:03pm UTC](https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642 "2023-05-26T13:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marschos](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Marschos](https://community.jenkins.io/u/Marschos)\
**Post date:** [May 26, 2023, 1:03pm UTC](https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642/1 "2023-05-26T13:03:31Z")

</div>

Hello!

I have a git multibranch pipeline and it´s set up with `options{ disableConcurrentBuilds() }`.  
This is working great but it does (at least) schedule build´s for other branches if there is changes.  
That´s not a problem by itself because the agent only can do one build at a time,  
but the scheduled build start´s on the agent with the head of the branch it saw during scanning in the past.

What I would prefer is that there will be no scanning while a build of the multibranch pipeline is active (or scheduled).

I suppose it would also work to explicitly check out the head in the pipeline, but then the commit´s shown in the webui would likely not match what has been built. (?)

Is there a way to achieve this?

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [May 29, 2023, 1:54pm UTC](https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642/2 "2023-05-29T13:54:41Z")

</div>

Hello @Marschos and welcome to this community 👋

What about using the [`disableRemotePoll()`](https://javadoc.jenkins.io/plugin/git/hudson/plugins/git/extensions/impl/DisableRemotePoll.html) option?

---

<div class="post-metadata">

**Author:** ![Marschos](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Marschos](https://community.jenkins.io/u/Marschos)\
**Post date:** [May 29, 2023, 3:21pm UTC](https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642/3 "2023-05-29T15:21:25Z")

</div>

Hi @poddingue and thanks for the warm welcome. 👋

That looks like it could be the solution. 🤔  
I am a little worried why I could not find this myself before. 😅

I will test it and let you know if it worked.

---

<div class="post-metadata">

**Author:** ![Marschos](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Marschos](https://community.jenkins.io/u/Marschos)\
**Post date:** [May 30, 2023, 12:21pm UTC](https://community.jenkins.io/t/prevent-scan-of-multibranch-pipeline-while-a-build-is-active/7642/4 "2023-05-30T12:21:57Z")

</div>

I tried the option, but it is not available. 🤔

```auto
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 7: Invalid option type "disableRemotePoll". Valid option types: [buildDiscarder, catchError, checkoutToSubdirectory, copyArtifactPermission, disableConcurrentBuilds, disableRestartFromStage, disableResume, durabilityHint, githubProjectProperty, overrideIndexTriggers, parallelsAlwaysFailFast, preserveStashes, quietPeriod, rateLimitBuilds, retry, script, skipDefaultCheckout, skipStagesAfterUnstable, timeout, timestamps, waitUntil, warnError, withChecks, withContext, withCredentials, withEnv, wrap, ws] @ line 7, column 3.
   		disableRemotePoll()

```

I thought this can be used as an option in the Pipeline script, but that is not the case. Or am I missing a plugin?

The test I made show´s my problem:

- A job builds Branch 1
- A change in main triggered a job that is waiting (Because the current job running is not of the same branch) but with a now fixed commit hash
- More changes in main and Branch1 scheduled a future build that will start with the head of their branch

![grafik](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/d/de56008e2c9edeaa9540cbcdfe4384870e85ec2e.png)

I am okay with the Scheduled builds that will build the latest once the job is created, I am not okay with the waiting job that will build something old.
