Skip to content

[JENKINS-75854] Do not fetch tags in multibranch Pipeline if "Discover tags" is not enabled - #1776

Merged
MarkEWaite merged 16 commits into
jenkinsci:masterfrom
amuniz:no-tags
Aug 1, 2025
Merged

[JENKINS-75854] Do not fetch tags in multibranch Pipeline if "Discover tags" is not enabled#1776
MarkEWaite merged 16 commits into
jenkinsci:masterfrom
amuniz:no-tags

Conversation

@amuniz

@amuniz amuniz commented Jul 1, 2025

Copy link
Copy Markdown
Member

See JENKINS-75854

If the "Discover Tags" trait is not set, there is no need to fetch tags on branch indexing.

Testing done

  • Create a multibranch job using the Git branch source
  • Make sure the "Discover Tags" trait is not added
  • Check that the git command that runs on branch indexing does not includes the --tags modifier
  • Now add the "Discover Tags" trait and trigger branch indexing
  • Check that the git command that runs on branch indexing includes the --tags modifier

Submitter checklist

  • 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 demonstrate the feature works or the issue is fixed

amuniz added 2 commits July 1, 2025 12:20
If the "Discover Tags" trait is not set, there is no need to fetch tags
on branch indexing.
@github-actions github-actions Bot added the tests Automated test addition or improvement label Jul 2, 2025
@amuniz

amuniz commented Jul 3, 2025

Copy link
Copy Markdown
Member Author

Tests failures in Windows. They are passing locally (and CI) in Linux. I don't have a Windows host to test this. @MarkEWaite maybe you can help me out here?

@amuniz
amuniz marked this pull request as ready for review July 3, 2025 08:28
@amuniz
amuniz requested a review from a team as a code owner July 3, 2025 08:28

@car-roll car-roll left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. I dug through the indexing code in branch-api just to make sure but I didn't see anything else there would cause this issue,

@amuniz amuniz changed the title Do not fetch tags if not needed [JENKINS-75854] Do not fetch tags if not needed Jul 4, 2025
@amuniz amuniz closed this Jul 4, 2025
@amuniz amuniz reopened this Jul 4, 2025
@amuniz

amuniz commented Jul 4, 2025

Copy link
Copy Markdown
Member Author

@olamy can you trigger a new build here to check if the Windows test failure was just a flake? I've tried by closing/reopening but that didn't work.

The refs/tags namespace should not have been retrieved previously when
tag discovery was not enabled.
@MarkEWaite

Copy link
Copy Markdown
Contributor

One of the failing tests was testing a condition that is no longer expected to exist. It was testing for ref/tags/v2 in a branch source that had not configured tag discovery. I deleted the failing assertion in 93fc47f

The assertion did not fail on Linux for me, just as it did not fail on Linux for @amuniz . Will need more investigation to understand why that assertion does not fail on Linux.

@amuniz

amuniz commented Jul 11, 2025

Copy link
Copy Markdown
Member Author

I've noticed in logs that the windows build is using a more recent git cli version (2.50) than the Linux build. I'm checking if this is the culprit.

@amuniz

amuniz commented Jul 11, 2025

Copy link
Copy Markdown
Member Author

I'm checking if this is the culprit.

Nop. AbstractGitSCMSourceTest#refLockEncounteredIfPruneTraitNotPresentOnNotFoundRetrieval passes on Linux with git 2.50.1 too.

@amuniz

amuniz commented Jul 11, 2025

Copy link
Copy Markdown
Member Author

@amuniz

amuniz commented Jul 14, 2025

Copy link
Copy Markdown
Member Author

Alright, unsetting org.jenkinsci.plugins.gitclient.Git.mockClient did the trick. Tests are good now.

@MarkEWaite this is ready for final review/merge/release

Comment thread src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java Outdated
amuniz and others added 6 commits July 15, 2025 10:09
Test the heads that are returned in combinations of traits.

Use Before and After methods to register the MockGitClient so that we
can avoid a try / finally block in the test.
Users may find that the bug fix has a negative impact on their environment
and may not be able to immediately adjust their multibranch Pipeline
definitions.  Accept a system property that restores the buggy behavior.
Tests the impact of GitSCMSource.IGNORE_TAG_DISCOVERY_TRAIT on the
behavior.

@MarkEWaite MarkEWaite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change looks very good to me, though I'm worried about users that may depend on the old (buggy) behavior and not be able to adapt their multibranch Pipeline definitions when the buggy behavior is fixed.

I've used your changes as a base and extended it by adding a "retain bug compatibility" property. @amuniz and @olamy could you review my changes at:

amuniz/git-plugin@no-tags...MarkEWaite:git-plugin:no-tags

I moved the new test into a separate file so that I could use the Before and After annotation to simplify the tests.

I split the single test into multiple tests so that I could see the assertions more readily.

I added assertions for the return value of source.fetch() and added comments when the return value was not what I expected.

@amuniz

amuniz commented Jul 16, 2025

Copy link
Copy Markdown
Member Author

Your proposed changes look good to me @MarkEWaite, feel free to incorporate them to this PR. Thanks!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 16, 2025
@MarkEWaite

Copy link
Copy Markdown
Contributor

@amuniz I have delayed merging this because I'm seeing two failures in my test controller when running on Linux. The same tests pass on ci.jenkins.io, but I need to resolve those failures before merging. The failing tests are:

  • GitSCMSlowTest.testMergeWithAgent
    Expected: (a collection containing </home/jagent/mark-pc2.markwaite.net-agent/workspace/lder_git-plugin-pipeline_no-tags@tmp/j h11846651444599217186/agent-work-dirs/slave0/workspace/test0/commitFileBase>)
         but: a collection containing </home/jagent/mark-pc2.markwaite.net-agent/workspace/lder_git-plugin-pipeline_no-tags@tmp/j h11846651444599217186/agent-work-dirs/slave0/workspace/test0/commitFileBase> was empty
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at hudson.plugins.git.AbstractGitTestCase.build(AbstractGitTestCase.java:251)
        at hudson.plugins.git.GitSCMSlowTest.testMergeWithAgent(GitSCMSlowTest.java:320)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:648)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.lang.Thread.run(Thread.java:1583)
    
  • GitSCMTest.testMerge
    Expected: (a collection containing </home/jagent/mark-pc2.markwaite.net-agent/workspace/lder_git-plugin-pipeline_no-tags@tmp/j h2509364304717279261/workspace/test0/commitFileBase>)
         but: a collection containing </home/jagent/mark-pc2.markwaite.net-agent/workspace/lder_git-plugin-pipeline_no-tags@tmp/j h2509364304717279261/workspace/test0/commitFileBase> was empty
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at hudson.plugins.git.AbstractGitTestCase.build(AbstractGitTestCase.java:251)
        at hudson.plugins.git.GitSCMTest.testMerge(GitSCMTest.java:2002)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.jvnet.hudson.test.JenkinsRule$1.evaluate(JenkinsRule.java:648)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
        at java.base/java.lang.Thread.run(Thread.java:1583)
    
    

I'll continue exploring to understand the issue. I assume it is purely a test issue and may somehow be related to the AbstractGitTestCase that is the basis of those two test classes and its testRepo.

@MarkEWaite MarkEWaite changed the title [JENKINS-75854] Do not fetch tags if not needed [JENKINS-75854] Do not fetch tags in multibranch Pipeline if "Discover tags" is not enabled Aug 1, 2025

@MarkEWaite MarkEWaite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Once merged to the master branch, I'll start the interactive testing.

@MarkEWaite
MarkEWaite enabled auto-merge (squash) August 1, 2025 21:17
@MarkEWaite
MarkEWaite merged commit faee06b into jenkinsci:master Aug 1, 2025
18 checks passed
@MarkEWaite MarkEWaite added bug Incorrect or flawed behavior and removed documentation Improvements or additions to documentation tests Automated test addition or improvement labels Aug 2, 2025
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Aug 2, 2025
Docker Java API update from 3.5.2 to 3.5.3 from pull request:

* jenkinsci/docker-java-api-plugin#138

Bumps the netty version dependency inside the API plugin from 4.1.119
to 4.2.2 but the Jenkins netty plugin is 4.1.118.  Need to confirm that
does not cause issues in plugin BOM tests.

Git plugin update from 5.7.0 to 5.8.0 includes pull request:

* jenkinsci/git-plugin#1776

That fixes https://issues.jenkins.io/browse/JENKINS-75854 and adjusts
the git plugin multibranch Pipeline scan to only request tags if the
Discover Tags trait is associated with the scan.

Git client plugin update from 6.2.0 to 6.3.0 increases the minimum Jenkins
version from 2.479.3 to 2.504.1.  Other changes are dependency updates.

Testing done:

PLUGINS=git,git-client,docker-plugin LINE=weekly bash ./local-test.sh
MarkEWaite added a commit to MarkEWaite/docker-lfs that referenced this pull request Aug 2, 2025
MarkEWaite added a commit to MarkEWaite/docker-lfs that referenced this pull request Aug 20, 2025
Includes:

* jenkinsci/git-plugin#1776 Do not fetch tags unless "Discover tags" is enabled
* jenkinsci/git-plugin#1789 Replace Commons Lang 2
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

Development

Successfully merging this pull request may close these issues.

4 participants