Reproduction test:
Run freestyle job with system groovy step:
import hudson.model.*
def thr = Thread.currentThread()
def build = thr?.executable
def jobName = build.parent.builds[0].properties.get("envVars").get("JOB_NAME")
def jobNr = build.parent.builds[0].properties.get("envVars").get("BUILD_NUMBER")
println "This is " + jobName + " running for the $jobNr:th time"
Now the above script is not a correct script, but use of Groovy's magic "proprerties" property exposes the file leak when instantiating the Run.getLogText() "property", you get file handle leaks like:
> java 19008 jenkins 587r REG 252,0 503 395865 /data/jenkins/jobs/automation/jobs/test-open-files/builds/7/log
> java 19008 jenkins 589r REG 252,0 503 395865 /data/jenkins/jobs/automation/jobs/test-open-files/builds/7/log
> java 19008 jenkins 590r REG 252,0 503 395865 /data/jenkins/jobs/automation/jobs/test-open-files/builds/7/log
> java 19008 jenkins 592r REG 252,0 503 395865 /data/jenkins/jobs/automation/jobs/test-open-files/builds/7/log
The differentiator from JENKINS-45057 is that these are READ locks not WRITE locks.
Reproduction test:
Run freestyle job with system groovy step:
Now the above script is not a correct script, but use of Groovy's magic "proprerties" property exposes the file leak when instantiating the Run.getLogText() "property", you get file handle leaks like:
The differentiator from
JENKINS-45057is that these are READ locks not WRITE locks.