Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip build on matched jobs if manual scan is clicked #12

Merged
merged 2 commits into from Oct 16, 2022

Conversation

zhan9san
Copy link
Contributor

@zhan9san zhan9san commented Nov 3, 2021

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

Jira Issue: JENKINS-67037

During all the test, no job is triggered.

As we can see, if Scan Multibranch Pipeline Now is clicked, as there is no change pushed to repository, the lastSeenRevision equals to currRevision in plugin log, the condition of isAutomaticBuild is changed to lastSeenRevision != null && !lastSeenRevision.equals(currRevision) from lastSeenRevision != null.

Test log:
Scan Multibranch Pipeline Log when multibranch job is firstly created

Started
[Wed Nov 03 06:47:39 UTC 2021] Starting branch indexing...
Connecting to https://bitbucket.example.com using fake-user/******
Repository type: Git
Looking up pdt/test-multi-branch-pipeline for branches
Checking branch f/3 from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
No automatic build triggered for f/3
Checking branch develop from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
No automatic build triggered for develop
Checking branch f/1 from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
No automatic build triggered for f/1
Checking branch master from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
No automatic build triggered for master

  4 branches were processed
Looking up fake-project/test-multi-branch-pipeline for pull requests

  0 pull requests were processed
[Wed Nov 03 06:47:51 UTC 2021] Finished branch indexing. Indexing took 11 sec
Finished: SUCCESS

plugin log when multibranch job is firstly created,

Nov 03, 2021 6:47:45 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: null, currRevision: e7bac7413385dba1dd7029ad3db5dc948346c3b1
Nov 03, 2021 6:47:47 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: null, currRevision: 98b83831844a0056b7730f4d3707d9b7dc00463b
Nov 03, 2021 6:47:49 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: null, currRevision: b6a11e686a6acd82cf90ea7dbf9b6e14bb0d43a6
Nov 03, 2021 6:47:51 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: null, currRevision: 9e3fe7ddb28c0d60950dc81989e170eb3ba8feb9

Scan Multibranch Pipeline Log after Scan Multibranch Pipeline Now is clicked

Started by user admin
[Wed Nov 03 06:51:09 UTC 2021] Starting branch indexing...
Connecting to https://bitbucket.example.com using fake-user/******
Repository type: Git
Looking up fake-project/test-multi-branch-pipeline for branches
Checking branch f/3 from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: f/3 (null → e7bac7413385dba1dd7029ad3db5dc948346c3b1)
No automatic build triggered for f/3
Checking branch develop from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: develop (null → 98b83831844a0056b7730f4d3707d9b7dc00463b)
No automatic build triggered for develop
Checking branch f/1 from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: f/1 (null → b6a11e686a6acd82cf90ea7dbf9b6e14bb0d43a6)
No automatic build triggered for f/1
Checking branch master from fake-project/test-multi-branch-pipeline
      ‘Jenkinsfile’ found
    Met criteria
Changes detected: master (null → 9e3fe7ddb28c0d60950dc81989e170eb3ba8feb9)
No automatic build triggered for master

  4 branches were processed
Looking up fake-project/test-multi-branch-pipeline for pull requests

  0 pull requests were processed
[Wed Nov 03 06:51:21 UTC 2021] Finished branch indexing. Indexing took 11 sec
Finished: SUCCESS

plugin log after Scan Multibranch Pipeline Now is clicked

Nov 03, 2021 6:51:15 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: e7bac7413385dba1dd7029ad3db5dc948346c3b1, currRevision: e7bac7413385dba1dd7029ad3db5dc948346c3b1
Nov 03, 2021 6:51:17 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: 98b83831844a0056b7730f4d3707d9b7dc00463b, currRevision: 98b83831844a0056b7730f4d3707d9b7dc00463b
Nov 03, 2021 6:51:19 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: b6a11e686a6acd82cf90ea7dbf9b6e14bb0d43a6, currRevision: b6a11e686a6acd82cf90ea7dbf9b6e14bb0d43a6
Nov 03, 2021 6:51:21 AM INFO jenkins.branch.buildstrategies.basic.SkipInitialBuildOnFirstBranchIndexing isAutomaticBuild
lastSeenRevision: 9e3fe7ddb28c0d60950dc81989e170eb3ba8feb9, currRevision: 9e3fe7ddb28c0d60950dc81989e170eb3ba8feb9

Copy link

@sams-gleb sams-gleb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to see this merged in, as it makes the "skip initial build" strategy more useful ) Also as this is not only about manual scans I'd rename it to something like "Avoid triggering new builds by reindex when SkipInitialBuild strategy is enabled and revision has not changed". This also solves JENKINS-63799

@zhan9san zhan9san merged commit b222fe7 into jenkinsci:master Oct 16, 2022
@zhan9san zhan9san deleted the feature/skip-first-manual-scan branch October 16, 2022 02:55
@zhan9san zhan9san mentioned this pull request Oct 17, 2022
3 tasks
@zhan9san zhan9san added the bug Incorrect or flawed behavior label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect or flawed behavior
Projects
None yet
2 participants