Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37577

While using Java File method, Jenkins is searching for the existence of file in master even though we run under slave node

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      Hi,

      While using Java File method, Jenkins is searching for the existence of file in master even though we run under slave node and throwing file not found exception.

      Below is our code

      import groovy.json.*
      
      def commonJsonFile
      def commonJsonText
      
      node('NETSEC_PUNE_SUSE11_X86_1') {
         commonJsonFile = new File('/temp/dev/pipeline/common.json')
         commonJsonText = new JsonSlurper().parseText(commonJsonFile.text)
      }
      
      println(commonJsonText.pspopensslv6.gitproject);
      
      

      Below is the error we got

      [Pipeline] node
      Running on NETSEC_PUNE_SUSE11_X86_1 in **********
      Pipeline] {
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      java.io.FileNotFoundException: /temp/dev/pipeline/common.json (No such file or directory)
      	at java.io.FileInputStream.open0(Native Method)
      	at java.io.FileInputStream.open(FileInputStream.java:195)
      	at java.io.FileInputStream.<init>(FileInputStream.java:138)
      	at groovy.util.CharsetToolkit.<init>(CharsetToolkit.java:71)
      	at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:1572)
      	at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:600)
      	at org.codehaus.groovy.runtime.dgm$962.doMethodInvoke(Unknown Source)
      	at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:73)
      	at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1852)
      	at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:3735)
      	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:177)
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:26)
      	at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
      	at WorkflowScript.run(WorkflowScript:10)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
      	at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
      	at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
      	at sun.reflect.GeneratedMethodAccessor414.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:361)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:226)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	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
      

        Attachments

          Activity

          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          The behavior is "as designed". Low-level Java commands will always access files on the master.
          There are Pipeline commands like readFile() and writeFile(), which allow accessing files within node workspaces.

          Show
          oleg_nenashev Oleg Nenashev added a comment - The behavior is "as designed". Low-level Java commands will always access files on the master. There are Pipeline commands like readFile() and writeFile(), which allow accessing files within node workspaces.

            People

            • Assignee:
              oleg_nenashev Oleg Nenashev
              Reporter:
              anudeeplalam Anudeep Lalam
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: