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

Git build chooser only obeys first child of the extensions section

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None
    • git-plugin 2.4.4
      Jenkins 1.653

      This issue was spun out of JENKINS-33695.

      Consider the following snippet from a job config.xml:

      <scm class="hudson.plugins.git.GitSCM" plugin="git@2.4.4">
      	<configVersion>2</configVersion>
      	<userRemoteConfigs>
      		<hudson.plugins.git.UserRemoteConfig>
      			<name>gitlab</name>
      			<url>[URL]</url>
      			<credentialsId>[CREDENTIAL]</credentialsId>
      		</hudson.plugins.git.UserRemoteConfig>
      	</userRemoteConfigs>
      	<branches>
      		<hudson.plugins.git.BranchSpec>
      			<name>**/master</name>
      		</hudson.plugins.git.BranchSpec>
      		<hudson.plugins.git.BranchSpec>
      			<name>**/bleeding</name>
      		</hudson.plugins.git.BranchSpec>
      	</branches>
      	<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
      	<submoduleCfg class="list"/>
      	<extensions>
      		<hudson.plugins.git.extensions.impl.BuildChooserSetting>
      			<buildChooser class="hudson.plugins.git.util.AncestryBuildChooser">
      				<maximumAgeInDays>14</maximumAgeInDays>
      				<ancestorCommitSha1/>
      			</buildChooser>
      		</hudson.plugins.git.extensions.impl.BuildChooserSetting>
      		<hudson.plugins.git.extensions.impl.BuildChooserSetting>
      			<buildChooser class="hudson.plugins.git.util.InverseBuildChooser"/>
      		</hudson.plugins.git.extensions.impl.BuildChooserSetting>
      	</extensions>
      </scm>
      

      According to this snippet, there should be two criteria for selecting a commit to build - it should both be less than 14 days old, and it should not be the master or bleeding branch (i.e. the chosen commit would be in the intersection of all BuildChooser selections).

      Currently, this is not the case, and the plugin will select any commit less than 14 days old for building.

      The breaking change seems to have been introduced in 2.4.1; 2.4.0 still produces the expected behavior.

          [JENKINS-33827] Git build chooser only obeys first child of the extensions section

          Mark Waite added a comment - - edited

          zmeggyesi I have started work to better understand the current behavior, in hopes of using that understanding to then compare it to past behavior so that I can find the commit which changed the behavior. Could you refer to my notes and see if they match your observations of the current behavior?

          I haven't yet done the same depth of experiments with git plugin 2.4.0, but my first experiment with git plugin 2.4.0 seemed to show the same behavior as git plugin 2.4.4.

          The job definitions I used for my experiments are recorded in that repository as well, in case you want to duplicate my tests, or try those same job definitions on different versions of the git plugin.

          As far as I can tell from reading the descriptions of the changes, there are no direct changes of the build chooser implementations since just before the release of git plugin 2.3.5. Is it possible that you were using multiple build chooser selections well before the release of git plugin 2.4.0?

          Mark Waite added a comment - - edited zmeggyesi I have started work to better understand the current behavior, in hopes of using that understanding to then compare it to past behavior so that I can find the commit which changed the behavior. Could you refer to my notes and see if they match your observations of the current behavior? I haven't yet done the same depth of experiments with git plugin 2.4.0, but my first experiment with git plugin 2.4.0 seemed to show the same behavior as git plugin 2.4.4. The job definitions I used for my experiments are recorded in that repository as well, in case you want to duplicate my tests, or try those same job definitions on different versions of the git plugin. As far as I can tell from reading the descriptions of the changes, there are no direct changes of the build chooser implementations since just before the release of git plugin 2.3.5. Is it possible that you were using multiple build chooser selections well before the release of git plugin 2.4.0?

          Definitely so. I've been using the same setup (migrating it between physical and virtual machines) for the better part of 1.5-2 years now, upgrading the plugins every month or two.

          Zalan Meggyesi added a comment - Definitely so. I've been using the same setup (migrating it between physical and virtual machines) for the better part of 1.5-2 years now, upgrading the plugins every month or two.

          Mark Waite added a comment -

          I have tested git plugin 2.3.1, 2.4.0, and 2.4.4 and confirmed that all three behave as documented in the README on my investigation branch. I'm not going to investigate further at this time.

          If you can find a git plugin version that has the behavior you are seeking, I'm interested to know which plugin version that is. As far as I can tell, all plugin versions treat the first build chooser as the defining build chooser.

          Mark Waite added a comment - I have tested git plugin 2.3.1, 2.4.0, and 2.4.4 and confirmed that all three behave as documented in the README on my investigation branch . I'm not going to investigate further at this time. If you can find a git plugin version that has the behavior you are seeking, I'm interested to know which plugin version that is. As far as I can tell, all plugin versions treat the first build chooser as the defining build chooser.

          Added a new BuildChooser to use both filtering options without altering the plugin significantly. Pull request submitted, awaiting decision.

          Zalan Meggyesi added a comment - Added a new BuildChooser to use both filtering options without altering the plugin significantly. Pull request submitted, awaiting decision.

          Assigning to Mark Waite for pull request acceptance - I'm not exactly familiar with the protocol, so forgive me if I'm wrong here...

          Zalan Meggyesi added a comment - Assigning to Mark Waite for pull request acceptance - I'm not exactly familiar with the protocol, so forgive me if I'm wrong here...

            Unassigned Unassigned
            zmeggyesi Zalan Meggyesi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: