• 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.

          [JENKINS-54012] File handle leak in Groovy Script

          Marco Pensallorto added a comment - - edited

          We encountered the very same problem. In our case, the file leak was in a shared bit of code ran by several jobs and overtime the number of open files grew in the hundreds of thousands . After rewriting that bit of code bypassing .enviroment the problem is gone. This is definitely a bug. Version 2.150.3 LTS here.

          Marco Pensallorto added a comment - - edited We encountered the very same problem. In our case, the file leak was in a shared bit of code ran by several jobs and overtime the number of open files grew in the hundreds of thousands . After rewriting that bit of code bypassing .enviroment the problem is gone. This is definitely a bug. Version 2.150.3 LTS here.

          Marie-Helene Touchette added a comment - - edited

          The problem is still there in version 2.249.1 LTS.

           I also went around it by changing the syntax from 

          build.properties.environment.BUILD_NUMBER

          to

          build.getEnvironment(listener).get('BUILD_NUMBER')

          Marie-Helene Touchette added a comment - - edited The problem is still there in version 2.249.1 LTS.  I also went around it by changing the syntax from  build.properties.environment.BUILD_NUMBER to build.getEnvironment(listener).get( 'BUILD_NUMBER' )

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

              Created:
              Updated: