Jenkins multibranch pipeline does not respect quiet period in Jenkinsfile
Asked Answered
A

2

11

I am using a Declarative Jenkinsfile with quiet period:

  options {
    quietPeriod(180)
    // more options
  }

Tool versions:

  • Jenkins - 2.190.3
  • Pipeline Multibranch Plugin - 2.21
  • Pipeline Declarative Plugin - 1.4.0

Now the issue is that on GitHub SCM changes, a standalone pipeline project respects the quiet period but a multibranch pipeline project does not. It returns no error either, just triggers the build immediately on receiving webhooks.

I am aware of the open issue JENKINS-37588 on this.

Using upstream wrapper jobs with build(job: 'my-job', quietPeriod: 180) is not feasible since I have several hundred multibranch projects.

Has anyone been able to find a solution or workable alternative? Any help will be appreciated.

Arevalo answered 18/1, 2020 at 16:57 Comment(5)
Basically, the options you declare for the pipeline are only limited to that specific branch. What is the result you are trying to achieve by using the quiet period?Cowpea
@Cowpea I want to prevent the Maven release plugin from triggering multiple builds in close succession while committing the pom.xml files. The quiet period works perfectly fine in the same Jenkins installation with freestyle Maven projects and standalone pipelines projects.Arevalo
It's possible to cancel running builds from later builds, hopefully before commit happens, do you think this may work for you?Cowpea
That works too just that quiet period is a cleaner way to achieve the same.Arevalo
also cancelling the builds not only is very ugly but also messes up any monitoring metrics of the builds and leaves the job overview in a really messy way, having to click through every job to see the if the "real" last build was successfulFrontiersman
F
4

I think - unfortunately - this is currently not possible.

There is an unresolved ticket here: https://issues.jenkins-ci.org/browse/JENKINS-37588

Also there is already an open pull request for this issue: https://github.com/jenkinsci/branch-api-plugin/pull/190

Frontiersman answered 24/6, 2020 at 9:39 Comment(1)
Meanwhile the PR is merged and the ticket is resolvedWhimsy
G
0

Quiet period was respected by multibranch pipeline after doing this:

  • In multi-branch pipeline, Configure > Branch sources > Property strategy > Add property > ‘Suppress automatic SCM triggering”

  • In Jenkinsfile, set build trigger to 'Poll SCM', but do not specify a schedule. This will only run due to SCM changes if triggered by a web hook. (I think if you are using GitHub you can select 'GitHub hook trigger for GITScm polling')

  • In Jenkinsfile, set quiet period.

  • Configure web hook on SCM.

    pipeline{
          agent{label "Linux" }
    
              options {
                 quietPeriod(180)
                // more options
              }
    
              triggers {
                  pollSCM ''
              }
    
              stages{
                  stage("Test"){
                      steps{
                          echo "Test"
                      }
                  }
              }
          }
    
Garrote answered 27/8, 2020 at 11:4 Comment(1)
Shouldn't the option be reflected in "View configuration" as well? It is not with me.Florin

© 2022 - 2024 — McMap. All rights reserved.