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

ConnectionHelper.java constructors call connectionRetry()

XMLWordPrintable

      The constructor for the ConnectionHelper class calls the 'connectionRetry()' method that opens up a connection to the perforce server regardless of whether the connection is needed or not.

      Example in action:

      • Monitor traffic to the perforce server using a network packet monitor such as wireshark
      • Connect to Jenkins from a browser.
      • Find a job that uses the Jenkins Perforce plugin
      • Click on ANY previous ran build from the left size of the window (i.e. items in the 'Build History')

      Wireshark will report a large amount of traffic to the Perforce server

      OK you might think that this isn't important, but if you have a Groovy script that parses old build jobs (checking say the environment variables that were used by the build) then each and every job that the script checks will generate hundreds of perforce network connections which are completely pointless. (slowing down the script in the process)

      An example groovy script that can be ran from the 'Script Console' window (Start wireshark and monitor network traffic to the perforce server before running the script)

      • String jobName = 'A_valid_Jenkins_job_that_uses_the_perforce_plugin';
        
        FreeStyleProject buildJob = Jenkins.instance.getItemByFullName(jobName);
        if(buildJob) {
             for(FreeStyleBuild job in buildJob.builds) {
        		println job.url;
        		job.getEnvironment(TaskListener.NULL).each { k, v ->
        			println '  | ' + k + ' = ' + v
        		}
        		println '';
        	}
        }
        

      There is absolutely no reason why the above script should generate any network traffic to the perforce server.

      (NOTE: Re-running the groovy script a 2nd time might produce less network traffic since I think there might be some caching somewhere)

            Unassigned Unassigned
            jbateman James Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: