Build in slave Jenkins with JDK not previously installed

5

I have a Jenkins server that orchestrates my build. Generally, it performs lighter builds, but I need slave to build GWT projects over the SSD. I have some freedom with this slave , but it is a borrowed resource from another company.

By the way, on this machine that the other company gave in kindly, there is a Jenkins server on which the product build of that other company is performed. And I would not want to bother with a possible JDK change without having control that the change will completely sandboxed so as not to affect the product of others.

Available build JDK options:

IconfiguredJenkinstobuildwithJDK8u91astheimage:

Obtainingthefollowingerrormessage:

  

InstallingPATH/TO/SLAVE/tools/hudson.model.JDK/JDK_8u91/jdk.exe
  [JDK_8u91]$PATH/TO/SLAVE/tools/hudson.model.JDK/JDK_8u91/jdk.exe/sADDLOCAL="ToolsFeature" REBOOT = ReallySuppress INSTALLDIR = PATH \ TO \ SLAVE \ tools \ hudson.model.JDK \ JDK_8u91 / L PATH \ TO \ SLAVE \ tools \ hudson.model.JDK \ install2115761959202298069log
  ERROR: SEVERE ERROR occurs
  org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException: Can not run program "PATH / TO / SLAVE / tools / hudson.model.JDK / JDK_8u91 / jdk.exe" (in directory "PATH \ TO \ SLAVE \ hudson.model.JDK \ JDK_8u91 "): CreateProcess error = 740, The requested operation requires elevation
  at org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables (EnvInjectVariableGetter.java:91)
    [... lines omitted because they appear to be irrelevant ...]
  Caused by: java.io.IOException: Can not run program "PATH / TO / SLAVE / hudson.model.JDK / JDK_8u91 / jdk.exe" (in directory "PATH \ TO \ SLAVE \ tools \ hudson.model.JDK \ JDK_8u91 "): CreateProcess error = 740, The requested operation requires elevation
  at java.lang.ProcessBuilder.start (Unknown Source)
    [... lines omitted because they appear to be irrelevant ...]
  Caused by: java.io.IOException: CreateProcess error = 740, The requested operation requires elevation
      at java.lang.ProcessImpl.create (Native Method)
    [... lines omitted because they appear to be irrelevant ...]

I accessed the slave server and ran the install command line manually at the prompt with administrator permissions:

PATH/TO/SLAVE/tools/hudson.model.JDK/JDK_8u91/jdk.exe /s ADDLOCAL="ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=PATH\TO\SLAVE\tools\hudson.model.JDK\JDK_8u91 /L PATH\TO\SLAVE\tools\hudson.model.JDK\install2115761959202298069log

However, when trying to build again, I get exactly the same error message. As if Jenkins had not identified the newly installed JDK.

When trying to select JDK8u25, Jenkins thought it was installed because it did not try to run the installer, but in reality it has an inconsistency in the system because the executable is not in the desired place:

  

[project-gwt] $ OTHER \ JENKINS \ tools \ hudson.model.JDK \ JDK_8u25 \ jdk1.8.0_25 / bin / java -cp PATH / TO / SLAVE / maven31-agent.jar; PATH \ TO \ SLAVE \ tools \ hudson.tasks.Maven_MavenInstallation \ MVN_311 \ boot \ plexus-classworlds-2.5.1.jar; PATH \ TO \ SLAVE \ tools \ hudson.tasks.Maven_MavenInstallation \ MVN_311 / conf / logging jenkins.maven3.agent.Maven31Main PATH /TO/SLAVE/tools/hudson.tasks.Maven_MavenInstallation/MVN_311 PATH \ TO \ USER \ AppData \ LocalLow \ Sun \ Java \ Deployment \ cache \ 6.0 \ 3 \ 893ffc3-1f519d29 PATH / TO / SLAVE / maven31-interceptor.jar PATH / TO / SLAVE / maven3-interceptor-commons.jar 51822
  ERROR: Failed to parse POMs
  java.io.IOException: Can not run program "OTHER \ JENKINS \ tools \ hudson.model.JDK \ JDK_8u25 \ jdk1.8.0_25 / bin / java" (in directory "PATH \ TO \ SLAVE \ workspace \ GeoSales_Portal \ portal") : CreateProcess error = 2, The system can not find the specified file
      at java.lang.ProcessBuilder.start (Unknown Source)
    [... lines omitted because they appear to be irrelevant ...]

  • How to install JDK via Jenkins on slave without high access?

About fixing the GWT project to make the build fast ... we're working on it. There are 109 classes dealing with asynchronous GWT requests, done by passing HashMap and receiving List or List<HashMap> in response. Yes, it was originally raw . But the work of the legacy is too large to fix, we have been working since last year between one customization and another to lessen the time the GWT is processing the oracle typing things up, or using specific classes for the required end.

But this is not feasible to fix in the short term ...

    
asked by anonymous 30.10.2017 / 14:55

2 answers

3

I'm still struggling to make a more elegant solution. I considered the stylish response from @ nunks.lol , putting the service and everything else, but as the server is Windows I just could not do much.

After getting tired of resolving smartly, I decided to try options on the go. So I found this link here that talks about configuring JDK on Jenkins and I noticed one important detail: / p>

  

JDK can also be installed by intimating Jenkins to do the task. The check box install automatically needs to be checked in this case.

Free translation:

  

JDK can also be installed by ordering Jenkins to perform the task. The check box "install automatically" needs to be checked in this case

Well, I had already managed to manually install the desired JDK. So what if I just wanted to avoid auto-install?

Well, I performed the manual installation:

PATH/TO/SLAVE/tools/hudson.model.JDK/JDK_8u151/jdk.exe /s ADDLOCAL="ToolsFeature" REBOOT=ReallySuppress INSTALLDIR=PATH\TO\SLAVE\tools\hudson.model.JDK\JDK_8u151 /L PATH\TO\SLAVE\tools\hudson.model.JDK\install2115761959202298069log

And, in the configuration of the Jenkins JDKs, I added the JDK JDK_8u151_SLAVE with check install automatically " deselected . It looks like this:

So,inthejobbuildIneededtouseslave,IselectedtorunwiththisJDK:

With this, Jenkins did not try to install over the installed JDK, using the already installed.

    
06.11.2017 / 15:54
2

I decided to register a response here, from of this Q & A and from documentation of the TestComplete tool, specifying settings required to run on Jenkins installations in Windows.

What brought me to this article was the heart of the error message presented in the question:

  

Caused by: java.io.IOException: CreateProcess error = 740, The requested operation requires elevation

In English, for future cross reference:

  

java.io.IOException: CreateProcess error = 740, The requested operation requires elevation.

This type of message occurs when it is required that the performing user has Administrator permissions, or at least higher permissions than an ordinary user, and by the comments you appear to be using slave via JNLP: how the server Remote opens a Jenkins master page and downloads an agent applet, useful for situations where the master can not open connection directly. The JNLP agent must be accessed and executed manually once on the remote machine and then installed as a service so that the manual procedure is no longer needed, as JNLP slave mode documentation .

So, from the error message that appears, there is a great possibility that your slave agent is not running as a service on remote Windows, without administrator permissions.

What causes me a certain strangeness is that it requires elevation to execute a JDK, something that I thought could be executed by any user:

  

ERROR: SEVERE ERROR occurs   org.jenkinsci.lib.envinject.EnvInjectException: java.io.IOException:    Can not run program    "PATH / TO / SLAVE / tools / hudson.model.JDK / JDK_8u91 / jdk.exe" (in directory   "PATH \ TO \ SLAVE \ hudson.model.JDK \ JDK_8u91"): CreateProcess error = 740, A   requested operation requires elevation   org.jenkinsci.plugins.envinject.service.EnvInjectVariableGetter.getBuildVariables (EnvInjectVariableGetter.java:91)

Is the slave's JDK configured to open network ports only accessible to privileged users? This would explain the analog error message in Linux, but I am not particularly versed in the security features of Windows.

In time, it may be a good idea to check out Jenkins documentation to see if some other slave configuration mode is no longer advantageous to you.

Another link that can help (I apologize if it's something very basic, as I said I do not know much about Windows and I have no machine here to test this setup ) is this article about Windows services , explaining how to register the execution of services, how to link them to specific users and how to give you interactive access to the user interface. If your Jenkins build needs to execute commands in the GUI, such as interacting with the mouse and keyboard, you may need to enable the latter property, and the error message received may result from this lack of permission, as quoted in the link at the beginning of this "answer" in the TestComplete documentation.

    
06.11.2017 / 04:45