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

Need to be able to customize BranchBuildStrategies to not build in the future. Not just a one time evaluataion.

    XMLWordPrintable

Details

    Description

      The use case:

      • Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
      • I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
      • I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

       

       

      I think the requirements are relatively simple and so is the implementation:

      • Here is where all branches come in the front door
      • It will always hit `observeNew` first.
        • We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
      • The next time a webhook/index comes in it hits `observeExisting`
        • Most times I notice it hits
          • if (changesDetected(revision, project, scmLastBuiltRevision)) {
        • changesDetected only evaluates last built revision. Problem 1
        • And it always hits lastSeenRevisionOrDefault which saves last seen revision
        • _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
      • So we should be able to do this in a 2 step process.
        1. Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
        2. Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

       

      #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.  In #2 I added SCMEvent as an extension of BuildBranchStrategy that allows us to see time of commit to help make less API calls to github.

      #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.

       

      I will start on #1

      Attachments

        Activity

          carpnick2 Nick Carpenter created issue -
          carpnick2 Nick Carpenter made changes -
          Field Original Value New Value
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeNew`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API)

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?)

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API)

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?)

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API)

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?)

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?)

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?)

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.

          - First Try for #2 - https://github.com/jenkinsci/branch-api-plugin/pull/291

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.

          - First Try for #2 - https://github.com/jenkinsci/branch-api-plugin/pull/291

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.  Any other extension points I am not thinking of?

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.
           - #1 - 
           - #2 - [https://github.com/jenkinsci/branch-api-plugin/pull/291]

           

          I will start on #1
          carpnick2 Nick Carpenter made changes -
          Summary Need to be able to customize definition of ChangesDetected Need to be able to customize BranchBuildStrategies to not build in the future. Not just a one time evaluataion.
          carpnick2 Nick Carpenter made changes -
          Description The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.  Any other extension points I am not thinking of?

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.
           - #1 - 
           - #2 - [https://github.com/jenkinsci/branch-api-plugin/pull/291]

           

          I will start on #1
          The use case:
           * Imagine I want to have an ephemeral Jenkins (Docker/K8S/etc).
           * I want it to be preconfigured with multibranch pipelines and/or Github/Bitbucket organization folders.
           * I want it to come online and when it does, it will scan for unknown repositories and branches and cause a build storm.

           
           * The Problem as I see it: 
           ## There are many plugins out there who try to deal with this, but none of them work fully.
           *** Build Strategy - [https://github.com/jenkinsci/basic-branch-build-strategies-plugin/blob/master/src/main/java/jenkins/branch/buildstrategies/basic/SkipInitialBuildOnFirstBranchIndexing.java]
           **** Doesnt fully work because the next time indexing runs - it builds.  So it delays the build storm.
           ## There are active PRs/Comments working to try to solve it different ways.
           *** https://issues.jenkins.io/browse/JENKINS-38552?focusedCommentId=289692&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-289692
           *** [https://github.com/jenkinsci/branch-api-plugin/pull/244]
           **** Solves some of it - but still assumes every webhook is delivered
           **** Their discussion - [https://github.com/jenkinsci/branch-api-plugin/pull/186
           ****

           

          I think the requirements are relatively simple and so is the implementation:
           * Here is where all branches come in the [front|https://github.com/jenkinsci/branch-api-plugin/blob/ac9234ee647afb58ad1cad65c145dc83f0cd6b7b/src/main/java/jenkins/branch/MultiBranchProject.java#L1984-L1986] door
           * It will always hit `observeNew` first.
           ** We can use a BuildStrategy to not run any build that has a commit older than some EPOCH time.
           * The next time a webhook/index comes in it hits `observeExisting`
           ** Most times I notice it hits
           *** if (changesDetected(revision, project, scmLastBuiltRevision)) {
           ** changesDetected only evaluates last built revision. Problem 1
           ** And it always hits lastSeenRevisionOrDefault which saves last seen revision
           ** _factory.setLastSeenRevisionHash(project, scmLastBuiltRevision);
           * So we should be able to do this in a 2 step process.
           ## Add build strategy that refuses to build if commit ID is not after a starting time (easily programmed on jenkins master startup)
           ## Have the branch-api-plugin have an option to save lastseenrevision as lastbuilt revision.

           

          #1 - Is a little harder since we are not handed any kind of probe so we have to hit Github right now (API) (More unnecessary API calls).  But it does stop the build.  In #2 I added SCMEvent as an extension of BuildBranchStrategy that allows us to see time of commit to help make less API calls to github.

          #2 - A literal property/config item - copy/boolean for when lastSeenRevisionOrDefault is called - also call  setRevisionHash on the same factory.  So if we have seen it (assume built).  (Is there anything wrong with this design?). Feature Flag?  Another option is to impact how `changesDetected` works or make it extendable.
           - #1 - 
           - #2 - [https://github.com/jenkinsci/branch-api-plugin/pull/291]

           

          I will start on #1
          pimsierhuis Pim Sierhuis added a comment -

          Wouldn't it be cleaner to store the revision during first indexing and pass that to the branch strategy, so the branch strategy can decide not to build when revison.equals(revisionDuringFirstIndexingHash)?

          Proof of concept here (without the passing to the branch strategy):

          https://github.com/pimsierhuis/branch-api-plugin/tree/revisionDuringFirstIndexing

           

          pimsierhuis Pim Sierhuis added a comment - Wouldn't it be cleaner to store the revision during first indexing and pass that to the branch strategy, so the branch strategy can decide not to build when revison.equals(revisionDuringFirstIndexingHash)? Proof of concept here (without the passing to the branch strategy): https://github.com/pimsierhuis/branch-api-plugin/tree/revisionDuringFirstIndexing  

          pimsierhuis - Yes, probably cleaner for the first requirement.  My thought on sending in the SCMEvent, it would open up this specific use case, and allows the rest of the code in `MultiBranchProject` to be mostly untouched.  Also, I was thinking if anyone else has other use cases where they want to selectively build based on what is in SCMEvent, this would allow them to create other extensions in the future.

          carpnick2 Nick Carpenter added a comment - pimsierhuis  - Yes, probably cleaner for the first requirement.  My thought on sending in the SCMEvent , it would open up this specific use case, and allows the rest of the code in `MultiBranchProject` to be mostly untouched.  Also, I was thinking if anyone else has other use cases where they want to selectively build based on what is in SCMEvent , this would allow them to create other extensions in the future.
          pimsierhuis Pim Sierhuis added a comment - - edited

          Well we can still pass the SCMEvent in too I guess. Just found it cleaner that the BuildStrategy gets all data it needs passed in at once, as in your approach it needs to store some information to answer the updatingLastBuiltRevisionWithNoBuild() call.

          What I'm also wondering (I just don't understand you solution completely I guess), is how you'll let the updatingLastBuiltRevisionWithNoBuild() call return true only for the revision during setup of the project.

          Also, that extra method complicates the concept behind things like AllBranchBuildStrategyImpl and AnyBranchBuildStrategyImpl. 

          pimsierhuis Pim Sierhuis added a comment - - edited Well we can still pass the SCMEvent in too I guess. Just found it cleaner that the BuildStrategy gets all data it needs passed in at once, as in your approach it needs to store some information to answer the updatingLastBuiltRevisionWithNoBuild() call. What I'm also wondering (I just don't understand you solution completely I guess), is how you'll let the updatingLastBuiltRevisionWithNoBuild() call return true only for the revision during setup of the project. Also, that extra method complicates the concept behind things like AllBranchBuildStrategyImpl and AnyBranchBuildStrategyImpl. 

          People

            Unassigned Unassigned
            carpnick2 Nick Carpenter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: