-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Minor
-
Component/s: nvm-wrapper-plugin
-
None
-
Environment:OS: Debian 9 x64
Jenkins 2.70 from pkg.jenkins.io
nvm-wrapper-plugin 0.1.3
The project where it's run is a Bitbucket Organization one, with Bitbucket Branch Soure plugin v2.2.2
When using nvm in my pipeline script, the workspace directory is not created and the pipeline fails. Â If I don't call nvm the workspace directory is created and the pipeline runs.
The pipeline script:
node() {
print "Workspace: ${WORKSPACE}"
nvm(version: 'v6.10.1') {
print "Workspace (nvm): ${WORKSPACE}"
sh 'env'
try {
stage('Checkout'){
checkout scm
}
stage('Dependencies and Build') {
env.NODE_ENV = "test"
print "Environment will be : ${env.NODE_ENV}"
sh 'node -v'
sh 'npm prune'
sh 'npm install'
sh 'npm run compile'
}
stage('Test'){
sh 'npm test'
}
stage('Cleanup'){
echo 'prune and cleanup'
sh 'npm prune'
sh 'rm node_modules -rf'
}
} catch (err) {
echo 'failed'
throw err
} finally {
echo 'done'
}
}
}
If I just remove the nvm() {...} to unwrap the pipeline contents it runs OK (given that node and npm are somewhere available in the $PATH).
The log of the failed run is the following one:
Lanzada por el usuario Marcos Replayed #13 [Pipeline] node Running on principal in /var/lib/jenkins/workspace/repo_master-LNZ3MEOGA46DNIXQLL6UPQJPEJKOANWZCDE5KZ6QPAABKL6ITL3Q [Pipeline] { [Pipeline] echo Workspace: /var/lib/jenkins/workspace/repo_master-LNZ3MEOGA46DNIXQLL6UPQJPEJKOANWZCDE5KZ6QPAABKL6ITL3Q [Pipeline] nvm [repo_master-LNZ3MEOGA46DNIXQLL6UPQJPEJKOANWZCDE5KZ6QPAABKL6ITL3Q] $ bash -c "export > before.env" [Pipeline] // nvm [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline [Bitbucket] Notifying commit build result [Bitbucket] Build result notified java.io.IOException: Process working directory '/var/lib/jenkins/workspace/repo_master-LNZ3MEOGA46DNIXQLL6UPQJPEJKOANWZCDE5KZ6QPAABKL6ITL3Q' doesn't exist! at hudson.Proc$LocalProc.<init>(Proc.java:247) at hudson.Proc$LocalProc.<init>(Proc.java:218) at hudson.Launcher$LocalLauncher.launch(Launcher.java:930) at hudson.Launcher$ProcStarter.start(Launcher.java:450) at hudson.Launcher$ProcStarter.join(Launcher.java:461) at org.jenkinsci.plugins.nvm.NvmWrapperUtil.getExport(NvmWrapperUtil.java:103) at org.jenkinsci.plugins.nvm.NvmWrapperUtil.getNpmEnvVars(NvmWrapperUtil.java:60) at org.jenkinsci.plugins.nvm.NvmStep$Execution.start(NvmStep.java:121) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:224) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16) at WorkflowScript.run(WorkflowScript:4) at ___cps.transform___(Native Method) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Finished: FAILURE
This is not a public Jenkins instance so I cannot link you to it, but I'll provide any additional required information.
Edit: forgot to mention that /var/lib/workspace is writable by the jenkins user and that it doesn't matter if job is run in the master or in an agent. Â Manually creating the directory with the jenkins user and replaying the pipeline, makes it run OK. Â Also adding a sh 'mkdir ${WORKSPACE}'Â statement at the top of the pipeline makes it run OK.
- mentioned in
-
Page Loading...