5

I've the following error in Jenkins console when running job which uses Windows slave:

Started by user 
  [EnvInject] - Loading node environment variables.
 ERROR: SEVERE ERROR occurs
 org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
 at org.jenkinsci.plugins.envinject.util.RunHelper.getBuildVariables(RunHelper.java:137)
 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironmentWithoutJobPropertyObject(EnvInjectListener.java:236)
 at org.jenkinsci.plugins.envinject.EnvInjectListener.setUpEnvironment(EnvInjectListener.java:50)
 at hudson.model.AbstractBuild$AbstractBuildExecution.createLauncher(AbstractBuild.java:534)
 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:454)
 at hudson.model.Run.execute(Run.java:1737)
...
 Caused by: java.io.IOException: remote file operation failed: C:\Program Files\Java\jre1.8.0_91 at hudson.remoting.Channel@2f4af34f:Management VPC Slave: Windows (sir-rvhi7z8q): java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
 at hudson.FilePath.act(FilePath.java:994)
 at hudson.FilePath.act(FilePath.java:976)
...
 Caused by: java.io.IOException: Unable to delete 'C:\Program Files\Java\jre1.8.0_91\bin\awt.dll'. Tried 3 times (of a maximum of 3) waiting 0.1 sec between attempts.
 at hudson.Util.deleteFile(Util.java:250)
 at hudson.FilePath.deleteRecursive(FilePath.java:1211)
...
Caused by: java.nio.file.AccessDeniedException: C:\Program Files\Java\jre1.8.0_91\bin\awt.dll
 at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)

which stops the job at the very start.

I've no idea why EnvInject plugin would want to remove some Java files (such as awt.dll).

Any idea how to solve this problem?

kenorb
  • 8,011
  • 14
  • 43
  • 80

1 Answers1

5

The EnvInject plugin is basically attempting to load the build environment which uses configuration of JDK tools in Jenkins which fails during reinstallation of Java JDK library on the Windows slave (as per given configuration).

This JDK configuration can be found in Global Tool Configuration (at /configureTools) for the given JDK profile which was selected in that job configuration. The installation process failed to reinstall Java JDK due to running Java process in the background (such as java -jar slave.jar) which was using these DLL files.
So it sounds like it's not possible to reinstall the same Java JDK files which are used to run the Jenkins slave process.

The solution was to disable Install automatically option in Global Tool Configuration, as Java JDK was already installed on that slave.

Jenkins, Java JDK, Install automatically option

Related: JENKINS-46989 - EnvInjectException: remote file operation failed.

Tensibai
  • 11,416
  • 2
  • 37
  • 63
kenorb
  • 8,011
  • 14
  • 43
  • 80