Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47077

"Periodically if not otherwise run" interval does not trigger index scan

    • 6.7

      I have set up a multibranch pipeline with Bitbucket Cloud repository.
      I am running jenkins locally, so I am not using webhooks.

      I've set "Periodically if not otherwise run" interval to 2 minutes, but repository is not being scanned for changes. Scanning can only be triggered manualy by "Scan Multibranch pipeline now".

      I've tried to set this up from blue ocean, then from old UI and no luck in both.
      Also using regular Git branch source instead of Bitbucket doesn't work.

      So I guess the problem is with multibranch pipeline itself.

          [JENKINS-47077] "Periodically if not otherwise run" interval does not trigger index scan

          Hmmm so https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/triggers/Trigger.java#L226 is responsible to call Trigger.checkTriggers periodically.

          https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/triggers/Trigger.java#L269 runs the triggers... but only on ParameterizedJobMixIn.ParameterizedJob (at least since this change) so how is the org folder getting triggered?

          Ahhh folders takes care of it itself

          Ok... so can people affected by this issue try running the following script in the system groovy console:

          for (def p in Jenkins.getInstance().allItems(com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.class)) {
              for (def t in p.getTriggers().values()) {
                if (t.tabs == null) println("${p.fullName} trigger ${t.class.name} not started");
              }
          }
          

          If you get a report of any of the triggers not being started then that would point to an NPE in FolderCron being the root cause.

          NOTE: I do not expect the above to be the cause. My Jenkins is on 2.89.4 and on a newly created org folder it is fine as well as on an existing org folder, e.g. see the following three screenshots that illustrate the org folder scan being daily and the multibranch scans being daily - but at different points in time - and I had not logged into my Jenkins in over a week before taking these screenshots!

          Stephen Connolly added a comment - Hmmm so https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/triggers/Trigger.java#L226 is responsible to call Trigger.checkTriggers periodically. https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/triggers/Trigger.java#L269 runs the triggers... but only on ParameterizedJobMixIn.ParameterizedJob (at least since this change ) so how is the org folder getting triggered? Ahhh folders takes care of it itself Ok... so can people affected by this issue try running the following script in the system groovy console: for (def p in Jenkins.getInstance().allItems(com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.class)) { for (def t in p.getTriggers().values()) { if (t.tabs == null ) println( "${p.fullName} trigger ${t. class. name} not started" ); } } If you get a report of any of the triggers not being started then that would point to an NPE in FolderCron being the root cause. NOTE: I do not expect the above to be the cause. My Jenkins is on 2.89.4 and on a newly created org folder it is fine as well as on an existing org folder, e.g. see the following three screenshots that illustrate the org folder scan being daily and the multibranch scans being daily - but at different points in time - and I had not logged into my Jenkins in over a week before taking these screenshots!

          What I do find interesting is this one:

          There is more than 24h since that one ran. It should run once every 24h, but it seems to be running every 48h.

          Hmmm H H * * * is the crontab... so if that picks any time before 19:49 then yesterday it would have been less than 24h since the last run and so it would only pick up the run today... presumably it will run at 19:49 today but the last triggered field will be out my some number of milliseconds and so effectively it runs every second interval

          Stephen Connolly added a comment - What I do find interesting is this one: There is more than 24h since that one ran. It should run once every 24h, but it seems to be running every 48h. Hmmm H H * * * is the crontab... so if that picks any time before 19:49 then yesterday it would have been less than 24h since the last run and so it would only pick up the run today... presumably it will run at 19:49 today but the last triggered field will be out my some number of milliseconds and so effectively it runs every second interval

          https://github.com/jenkinsci/cloudbees-folder-plugin/pull/119 might fix the incidental issue of "every minute" not running every minute... but it would be really good to understand how others are not getting the child multibranch scan being triggered at least once every two days?

          OR is it being triggered once every two days, but the org folder is set to a higher interval and thus "longer than every 2 days" is being translated into "never" because people are manually triggering as a workaround to being unable to configure the child triggers

          Stephen Connolly added a comment - https://github.com/jenkinsci/cloudbees-folder-plugin/pull/119 might fix the incidental issue of "every minute" not running every minute... but it would be really good to understand how others are not getting the child multibranch scan being triggered at least once every two days? OR is it being triggered once every two days, but the org folder is set to a higher interval and thus "longer than every 2 days" is being translated into "never" because people are manually triggering as a workaround to being unable to configure the child triggers

          Andy Airey added a comment -

          We have to scan all our multibranch pipeline repositories separately and cannot configure them (yet) as stated above...
          Otherwise the branch and PR jobs never get triggered.

          Also the new Bitbucket webhooks are not supported (JENKINS-47891) yet so we are kind of stuck  as we cannot install extra plugins on Bitbucket Server.
          This is really annoying.

          Andy Airey added a comment - We have to scan all our multibranch pipeline repositories separately and cannot configure them (yet) as stated above... Otherwise the branch and PR jobs never get triggered. Also the new Bitbucket webhooks are not supported ( JENKINS-47891 ) yet so we are kind of stuck  as we cannot install extra plugins on Bitbucket Server. This is really annoying.

          Michael Slattery added a comment - - edited

          As a workaround, we created a pipeline job as follows:

          import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject;
          node {
              Jenkins.instance.items
              .findAll { it instanceof WorkflowMultiBranchProject }
              .each {
                  echo it.name
                  it.indexing.run()
              }
          }
          

          I set it to trigger to build periodically, every two minutes: H/2 * * * *

          But, I had to do script approvals.  This is temporary for us until this bug gets fixed, after which I'll remove this job and the script approvals.

          Michael Slattery added a comment - - edited As a workaround, we created a pipeline job as follows: import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject; node { Jenkins.instance.items .findAll { it instanceof WorkflowMultiBranchProject } .each { echo it.name it.indexing.run() } } I set it to trigger to build periodically, every two minutes: H/2 * * * * But, I had to do script approvals.  This is temporary for us until this bug gets fixed, after which I'll remove this job and the script approvals.

          Derek Sudduth added a comment -

          stephenconnolly, I noticed this was marked as resolved. There are no comments regarding the fix or release. Do you know when we can expect to pick up the new plugin version? And what that version will be?

          Thanks in advance!

          Derek

          Derek Sudduth added a comment - stephenconnolly , I noticed this was marked as resolved . There are no comments regarding the fix or release. Do you know when we can expect to pick up the new plugin version? And what that version will be? Thanks in advance! Derek

          dsudduth I think it is released as 6.7 - https://plugins.jenkins.io/cloudbees-folder

          Aurimas Navardauskas added a comment - dsudduth I think it is released as 6.7 -  https://plugins.jenkins.io/cloudbees-folder

          Derek Sudduth added a comment -

          Thanks Aurimas, looks like it's the subdirectories (child jobs) that still exhibit the issue. That's what I'm experiencing after reading Stephen's comments further.

          Derek Sudduth added a comment - Thanks Aurimas, looks like it's the subdirectories (child jobs) that still exhibit the issue. That's what I'm experiencing after reading Stephen's comments further.

          Subfolders have their own period of scanning that is not the period of the parent

          Stephen Connolly added a comment - Subfolders have their own period of scanning that is not the period of the parent

          Derek Sudduth added a comment -

          stephenconnolly - You're correct. There are settings generated for each repo where a Jenkinsfile is detected. However, there is an issue with permissions when dynamically generating jobs. The settings are viewable, but permissions are denied. Separate issue, I know. But, it does make it challenging to modify the scan interval.

          Looks like more of a global issue outside the scope of this plugin. It is also seen in the Github plugin.

          https://stackoverflow.com/questions/48654556/jenkins-how-to-set-the-periodic-scan-interval-of-jobs-under-github-organization

          Derek Sudduth added a comment - stephenconnolly - You're correct. There are settings generated for each repo where a Jenkinsfile is detected. However, there is an issue with permissions when dynamically generating jobs. The settings are viewable, but permissions are denied. Separate issue, I know. But, it does make it challenging to modify the scan interval. Looks like more of a global issue outside the scope of this plugin. It is also seen in the Github plugin. https://stackoverflow.com/questions/48654556/jenkins-how-to-set-the-periodic-scan-interval-of-jobs-under-github-organization

            stephenconnolly Stephen Connolly
            wojciechrak Wojciech Rak
            Votes:
            9 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: