branch-api-plugin icon indicating copy to clipboard operation
branch-api-plugin copied to clipboard

JENKINS-67725 - Extending BranchBuildStrategies to allow setting last revision built + access to SCMEvent

Open carpnick opened this issue 3 years ago • 3 comments

See JENKINS-67725 for more context.

  • [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • [x] Ensure that the pull request title represents the desired changelog entry
  • [x] Please describe what you did
  • [x] Link to relevant issues in GitHub or Jira
  • [x] Link to relevant pull requests, esp. upstream and downstream changes
  • [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue

The basic use case:

  • How do we enable the folks to "save" the first commit ID found, and only build everything after that. This update allows us to implement a BranchBuildStrategy to do that. Without this change we are not handed the right pieces to implement that use case.

Discussion

  • As written this will always evaluate to true even if a BuildStrategy keeps responding, do not build. The next time a branch indexing comes in, it will evaluate to true since it did not build. This feels like a design flaw. As a plugin author I am telling you to not build it. As a Jenkins Admin I am telling you not to build it. But you are repeatedly trying to build it if I turn on branch indexing.
  • As I see it we have 2 options
    • We extend BranchBuildStrategy and add another optional method that allows a plugin author to own if you can update the last built hash
    • We create a whole new extension point to give a plugin author the ability to define what changesDetected means.

What is in the PR

  • Added a new extension method(optional) for plugin authors can choose to update last built revision or not. Default is false which is current behavior
  • Added integration of new method into MultiBranchProject to evaluate if it should update lastbuiltrevision on disk if told not to build.
  • Also added SCMEvent to the extension methods. Allows plugin authors to use properties to determine if we should build the artifact. The specific property I am looking for is timestamp. If I create a plugin that requires only building forward(from now) I need to know when the event was generated. This gives me that ability.

Please review at your convenience. This is ready.

carpnick avatar Feb 03 '22 08:02 carpnick

Could I get a review @jtnord and/or @rsandell ?

carpnick avatar Feb 14 '22 14:02 carpnick

Any kind of review would be appreciated... @timja or @car-roll

carpnick avatar Mar 01 '22 13:03 carpnick

I would also expect at least one downstream PR to demonstrate this new API.

ref: https://www.jenkins.io/doc/developer/extensions/branch-api/#branchbuildstrategy

Fair comment - I will either do a PR in one of the plugins that exists and/or create a plugin and link it here.

carpnick avatar Mar 07 '22 00:03 carpnick