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

File handle leak in Groovy Script

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • groovy-plugin
    • None
    • Jenkins ver. 2.145
      Jenkins ver. 2.150.3 LTS

      We use Groovy script in inject variables phase:

      // code placeholder
      import hudson.model.*;
      def thr = Thread.currentThread();
      def build = thr?.executable;
      
      String os = build.properties.environment.OS_TYPE.toString();
      String os_ver = build.properties.environment.OS_VERSION.toString();
      String panel =  build.properties.environment.PANEL_NAME.toString();
      String panel_ver =  build.properties.environment.PANEL_VERSION.toString();
      String bnum =  build.properties.environment.BUILD_NUMBER.toString();
      String gerrit =  build.properties.environment.GERRIT_REF.toString();
      
      String build_link =  build.properties.environment.BUILD_SYSTEM_REPO_IDS.toString();
      String author =  build.properties.environment.CREATED_BY.toString();
      String gerrit_link = ""
      
      build.displayName = "#" + bnum + " " + os+"_"+os_ver +" " + panel+"_"+panel_ver;if (gerrit.substring(0,5)=="refs/")  {
        gerrit_link = "https://somelink/#/c/"+gerrit.split('/').drop(3).join('/');
      }
      else {
        gerrit_link = "https://somelink/#/q/status:closed+project:project+branch:"+gerrit;
      }
      def tags ="";
      def gerrit_tests = "";def title = ""+gerrit+"\ntagged: "+tags+"\nBuild: "+build_link+"\nTests:⌥"+gerrit_tests+"\nCreated by: "+author+"\n"build.causes.each { cause ->
      title = title + cause.getShortDescription();
      }build.description = "⌥<a title=\""+title+"\" href="+gerrit_link+">"+gerrit+"</a><br />Build: <a href=https://somelink/#/build/"+build_link+">"+build_link+"</a><br />Created by: "+author;
      def map = [:];
      return map;
      

      And each build.properties.environment.VAR call left 2 file handlers opened to /var/lib/jenkins/jobs/job name/builds/NN/log

      As we use this script 5 times in one test run and have 8 numbers of environment call, we have 80 opened file handlers after each start. Five test run and here 300 opened files.

      When I removed build.properties.environment.VAR - opened files disappeared.

      I found a way to rewrite the script and don't use build.properties.environment - but think that's a bug.

            vjuranek vjuranek
            zztalker Pavel Zaikin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: