Prevent scan of Multibranch-Pipeline while a build is active

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?

Hello @Marschos and welcome to this community :wave:

What about using the disableRemotePoll() option?

Hi @poddingue and thanks for the warm welcome. :wave:

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

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

1 Like

I tried the option, but it is not available. :thinking:

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

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.