Closed RoiEXLab closed 3 years ago
@RoiEXLab it seems like setting the method to script might be a better choice for this use case anyhow. I'm looking at doing it this way:
launcher.launch()
.pwd(workspace)
.envs("NVM_METHOD=script")
.cmdAsSingleString("bash -c ./nvm-installer")
.stdout(listener.getLogger())
.stderr(listener.getLogger())
.join();
If I'm understanding correctly, I think this should fix things for your use case.
Well that would be an option too
@RoiEXLab I went ahead and made that change, which should be part of 0.2.0, once everything wends its way and propagates through the Jenkins ecosystem. Please reopen this issue if 0.2.0 doesn't fix it for you. Thanks for trying out the plugin!
Thank you very much
This is a weird one, I'll try to provide as much context as possible.
Basically I'm trying to create a build step for a standalone yarn project. That's why I added this plugin to jenkins and configured it to run install test and lint, so far so good. This plugin uses NVM and the nvm git repository to install nodejs and everything related, which is good. However, the install.sh script found at the nvm repository detects if there's git and if it is, it tries to use git to clone the whole repository for further installation. Now here's the problem: Due to some questionable company policy the git protocol is blocked for everything that's not company related i.e. GitHub, but the install script itself downloaded fine, because it was downloaded over the direct github URL, which is not blocked. Conveniently enough the nvm install script provides a so-called "script-method", which means that if the environment variable
METHOD
is set to the valuescript
, it will instead download the files individually instead using curl or wget, which means that the installer works even in my restricted environment.Setting the environment variable is tricky though and I haven't found a way to set it, causing this plugin pick it up (env injector plugin doesn't seem to work, global env variables don't seem to be working either), but I thought I found a smart woraround for it: I added a shell script step which runs the following code:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | METHOD=script bash
The idea behind it was to download nvm using the method that works and I was assumung the plugin would just skip installation if it detects that nvm is already present. And it looks like the code for it does in fact exist: https://github.com/jenkinsci/npm-yarn-wrapper-steps-plugin/blob/527f8be52db231eeed0dc7f2da03341a31a16303/src/main/java/io/interrogate/npmyarnwrappersteps/plugin/NVMUtilities.java#L27-L29 If I run this code in the script console it successfully detects the file in the.nvm
directory, but inside the Pull-Request-Builder the commandbash -c ./nvm-installer
regardless, tries to rungit fetch
inside the/home/jenkins/.nvm
directory failing due to the company policy I meantioned earlier.So to solve my problem one of 2 things would need to happen:
.nvm
directory, so the script isn't re-executed whenever the directory already exists. This would be a bug report, but I can't really find a flaw with the current approach, so it might be related to this particular jenkins setup which might be hard to fix, no idea here though.Any help with this problem would be very appreciated, I'd be happy to provide additional context if required.