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

can not change workspace in k8s pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • kubernetes-plugin
    • None

      I am a developer of the go language, running tests using the jenkins k8s agent. I need to put my workspace into GOPATH. But when I switch the working directory using `ws / dir`, I get the following error.

       

       

       

      Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 10.244.5.0/10.244.5.0:58310
      		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
      		at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
      		at hudson.remoting.Channel.call(Channel.java:955)
      		at hudson.FilePath.act(FilePath.java:1071)
      		at hudson.FilePath.act(FilePath.java:1060)
      		at hudson.FilePath.mkdirs(FilePath.java:1245)
      		at org.jenkinsci.plugins.durabletask.FileMonitoringTask$FileMonitoringController.<init>(FileMonitoringTask.java:171)
      		at org.jenkinsci.plugins.durabletask.BourneShellScript$ShellController.<init>(BourneShellScript.java:197)
      		at org.jenkinsci.plugins.durabletask.BourneShellScript$ShellController.<init>(BourneShellScript.java:189)
      		at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:110)
      		at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:98)
      		at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:264)
      		at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:270)
      		at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:180)
      		at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      		at sun.reflect.GeneratedMethodAccessor616.invoke(Unknown Source)
      		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:157)
      		at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      		at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:155)
      		at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
      		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
      		at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
      		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.GeneratedMethodAccessor497.invoke(Unknown Source)
      		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.ConstantBlock.eval(ConstantBlock.java:21)
      		at com.cloudbees.groovy.cps.Next.step(Next.java:83)
      		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
      		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
      		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:163)
      		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34)
      		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
      		at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
      		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58)
      		at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
      		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
      		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:131)
      		at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      		at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
      		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:1149)
      		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      java.nio.file.AccessDeniedException: /go
      	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      	at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
      	at java.nio.file.Files.createDirectory(Files.java:674)
      	at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
      	at java.nio.file.Files.createDirectories(Files.java:767)
      	at hudson.FilePath.mkdirs(FilePath.java:3272)
      	at hudson.FilePath.access$1300(FilePath.java:212)
      	at hudson.FilePath$Mkdirs.invoke(FilePath.java:1253)
      	at hudson.FilePath$Mkdirs.invoke(FilePath.java:1249)
      	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3085)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
      	at hudson.remoting.Request$2.run(Request.java:369)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
      	at java.lang.Thread.run(Thread.java:748)
      Finished: FAILURE
      

       

      my jenkinsfile is 

       

      pipeline {
        agent {
          kubernetes {
            label 'golang-sample'
            yaml '''
      apiVersion: v1
      kind: Pod
      metadata:
        labels:
          app: docker-builder
      spec:
        containers:
        - name: golang
          image: golang:1.10-alpine
          command:
          - cat
          tty: true
      '''
            defaultContainer 'golang'
          }
      
        }
        stages {
      		stage('test'){
      			steps{
      				dir('/go/src/github.com/runzexia/kubesphere-devops-sample-bin'){
      				    container('golang'){
      					sh 'pwd && ls -a'
      				    }
      				}
      			}
      		}
        }
      }
      
      pipeline {
        agent {
          kubernetes {
            label 'golang-sample'
            yaml '''
      apiVersion: v1
      kind: Pod
      metadata:
        labels:
          app: docker-builder
      spec:
        containers:
        - name: golang
          image: golang:1.10-alpine
          command:
          - cat
          tty: true
      '''
            defaultContainer 'golang'
          }
      
        }
        stages {
      		stage('test'){
      			steps{
      				ws('/go/src/github.com/runzexia/kubesphere-devops-sample-bin'){
      				    container('golang'){
      					sh 'pwd && ls -a'
      				    }
      				}
      			}
      		}
        }
      }
      

       

            Unassigned Unassigned
            runzexia runze xia
            Votes:
            3 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: