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

Branch indexing occurring for every multibranch job execution

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • p4-plugin
    • 1.11.2
      Jenkins 2.235.1

      When a job runs in the console log for that job 'p4 changes -m1' is run for every branch that matches the multibranch project source. For example the following job is running for '//streams/main':

       

      p4 client -i 
      Client  jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b saved.(p4):stop:8
      (p4):cmd:
      ...   View:
            //depot/multibranch/dev1/Jenkinsfile //jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b/Jenkinsfile
      
      p4 client -i 
      Client jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b saved.(p4):stop:17
      (p4):cmd:
      ...   View:
            //depot/multibranch/dev2/Jenkinsfile //jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b/Jenkinsfile
      
      p4 client -i 
      Client jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b saved.(p4):stop:26
      (p4):cmd:
      ...   View:
            //depot/multibranch/main/Jenkinsfile //jenkinsTemp-c31cbc7b-5563-4c2e-96e4-60fc95703f4b/Jenkinsfile

      Note that clients are created for 'dev1', 'dev2' and 'main' even though we only need to probe for changes to 'main' in this job execution. (Full console log attached)

       

      I would expect this in the Multibranch Scan Log but not every job execution.

       

      Reproduction steps:

      (1) Create following folders in Perforce and submit a Jenkinsfile to each:

      //depot/multibranch/dev1/...

      //depot/multibranch/dev2/...

      //depot/multibranch/main/...

      (2) Create a multibranch project with Helix Branches as the source and 'include branches' set to:

      //depot/multibranch/...

      and Scan Multibranch triggers set to '5 minutes'.

      (3) Manually build each job.

      (4) Submit a new file to '//depot/multibranch/main/...'.

      (5) Manually build the job. See that all branches are scanned in the console log for the main build job.

      (6) Submit another new file to '//depot/multibranch/main/...'.

      (7) Wait 5 minutes. See that all branches are scanned in the console.log and the Multibranch scan log.

       

       

       

          [JENKINS-64946] Branch indexing occurring for every multibranch job execution

          It will be helpful to avoid the Jenkins p4 plugin prebuilt scanning of every branch because the job is already running on a known path.

          In our case, the plug-in scans up to 400 paths (not related to our Jenkins job) and it takes up to 17 minutes on our larger paths. This extra scanning is time-consuming and generates thousands of unnecessary output lines.

          Vlasta Platonov added a comment - It will be helpful to avoid the Jenkins p4 plugin prebuilt scanning of every branch because the job is already running on a known path. In our case, the plug-in scans up to 400 paths (not related to our Jenkins job) and it takes up to 17 minutes on our larger paths. This extra scanning is time-consuming and generates thousands of unnecessary output lines.

          Mathew Bailey added a comment -

          Hi,

          This issue is causing us quite a delay at the start of every job. Is there a workaround for it, or a likely ETA for a fix? Is it possible to stop the Perforce account from being able to see the streams? I've experimented with the viewstreamspec permission but it didn't do what I was hoping for.

          Kind regards,

          Mat Bailey

          Mathew Bailey added a comment - Hi, This issue is causing us quite a delay at the start of every job. Is there a workaround for it, or a likely ETA for a fix? Is it possible to stop the Perforce account from being able to see the streams? I've experimented with the viewstreamspec permission but it didn't do what I was hoping for. Kind regards, Mat Bailey

          Karl Wirth added a comment -

          Hi unit2matbailey,

          One of the developers just told me to try using the 'Include Filter' and for me that works around the problem. For example my simple test above where I restrict to only 'main':

          I only see 'p4 changes' against main:

           

          Started
          [Mon Mar 14 14:06:51 UTC 2022] Starting branch indexing...
          ... p4 dirs //depot/multibranch/* +
          
          ... p4 changes -m1 -ssubmitted //jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950/...@2___ +
          P4: no revisions under //jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950/...@2259,2359
          ... p4 changes -m1 //depot/multibranch/main/...@2259,2359 +
          Scanning for //depot/multibranch/main/Jenkinsfile
          ... p4 files -e //depot/multibranch/main/Jenkinsfile +
                ‘Jenkinsfile’ found
          No changes detected: main (still at 107)
          ... p4 client -d jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950 +
          [Mon Mar 14 14:06:52 UTC 2022] Finished branch indexing. Indexing took 91 ms
          Finished: SUCCESS
          

          You can also use the Advanced... > Exclude Pattern. For example:

           

           

          Are you able to test that?

          Regards,

          Karl

          Karl Wirth added a comment - Hi unit2matbailey , One of the developers just told me to try using the 'Include Filter' and for me that works around the problem. For example my simple test above where I restrict to only 'main': I only see 'p4 changes' against main:   Started [Mon Mar 14 14:06:51 UTC 2022] Starting branch indexing... ... p4 dirs //depot/multibranch/* + ... p4 changes -m1 -ssubmitted //jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950/...@2___ + P4: no revisions under //jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950/...@2259,2359 ... p4 changes -m1 //depot/multibranch/main/...@2259,2359 + Scanning for //depot/multibranch/main/Jenkinsfile ... p4 files -e //depot/multibranch/main/Jenkinsfile + ‘Jenkinsfile’ found No changes detected: main (still at 107) ... p4 client -d jenkinsTemp-dbaa6e37-1a10-4aa1-8d90-5ebc1be67950 + [Mon Mar 14 14:06:52 UTC 2022] Finished branch indexing. Indexing took 91 ms Finished: SUCCESS You can also use the Advanced... > Exclude Pattern. For example:     Are you able to test that? Regards, Karl

          Paul Allen added a comment -

          Ready for release.

          Paul Allen added a comment - Ready for release.

          Paul Allen added a comment -

          Released in 1.12.3

          Paul Allen added a comment - Released in 1.12.3

            Unassigned Unassigned
            p4karl Karl Wirth
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: