yet-another-docker-plugin icon indicating copy to clipboard operation
yet-another-docker-plugin copied to clipboard

Support option to customize Java

Open samrocketman opened this issue 8 years ago • 8 comments

Right now, init.sh only supports java and depends on the $PATH to sort out which version. In the SSH launcher, the java binary path can be specified.

It would be nice to be able to specify the Java path without using environment variables or tools.

samrocketman avatar May 03 '17 00:05 samrocketman

Slave template has node properties, probably you can append PATH via it += or somehow. Afair jenkins had append vars magic.

KostyaSha avatar May 03 '17 00:05 KostyaSha

Except: https://github.com/KostyaSha/yet-another-docker-plugin/blob/80c991f821c3a68354e8c744c9fd876810f88e28/yet-another-docker-plugin/src/main/resources/com/github/kostyasha/yad/launcher/DockerComputerJNLPLauncher/init.sh#L103

Running su - ... will create a clean environment discarding any customization Jenkins would make from the environment or path side.

samrocketman avatar May 03 '17 00:05 samrocketman

but some vars will be added during build. Ok that not right level that i thought about. Some vars will be added only after jenkins slave.jar run and you mean before executing slave.jar..

KostyaSha avatar May 03 '17 00:05 KostyaSha

One of my ideas was to expose this whole script as configurable field in launcher. But the part of "contract" is property file. And hard user modifications may end with errors...

KostyaSha avatar May 03 '17 00:05 KostyaSha

Correct, I mean before executing slave.jar. A desired scenario is to run the same version of Jenkins as the master across different platforms.

samrocketman avatar May 03 '17 00:05 samrocketman

https://github.com/KostyaSha/yet-another-docker-plugin/blob/98ecf0a17ccbab6ba6913bdb82f97f6de54fb0bb/yet-another-docker-plugin/src/main/java/com/github/kostyasha/yad/launcher/DockerComputerSingleJNLPLauncher.java#L247-L257

We could take advantage of ${parameter:-word} bash parameter expansion. For example, in DockerComputerSingleJNLPLauncher.java you could add to config.sh the following where getJavaPath() is a hypothetical user defined Java executable:

...
"JAVA_PATH=\"" + getJavaPath() + NL +
...

In init.sh you could define:

...
RUN_CMD="${JAVA_PATH:-java}"
...

In the above scenario, if a user defines the JAVA_PATH then it will use that. Otherwise, it will fall back to java which is like the original script.

samrocketman avatar May 03 '17 00:05 samrocketman

somehow missed comment. Yes we can try, but then it will be impossible enforce setting when we don't wan't to follow container vars. I think at some point init.sh could be made as extension with chosable things + bind vars...

KostyaSha avatar Oct 09 '17 07:10 KostyaSha

However you want to do it is fine. I'm just commenting to try to add ideas.

samrocketman avatar Oct 09 '17 17:10 samrocketman