I have the following example pipeline

#!/usr/bin/env groovy
@Library('[email protected]') _

pipeline {
  agent {
    kubernetes {
      label buildId()
      containerTemplate {
        name 'node'
        image 'node:8.9.4-alpine'
        ttyEnabled true
        command 'cat'
      }
    }
  }
  stages {

    
    stage('Build') {
      steps {
        sh "echo npm run build"
        
        // stash build directory
        //stash includes: 'build/**', name: 'app'
      }
    }

    stage('Unit Test') {
      steps {
        script {
          try {
            sh "echo npm run test"
          } catch (err) {
            println "Failed"
          //} finally {
           // junit 'build/reports/**/*.xml'
          }
        }
      }
    }
    
    stage('Package') {
      agent { node { label 'docker1' } }
      options { skipDefaultCheckout() }
      steps {
        sh "/bin/sleep 120"
      }
    }
    
  }
}


What happens is that on the Package stage I get the following error:

[_location-service_PR-2-head-RP4JKIYE4QYJREC2YOQQGNKQG5UC56YLZET3VDC2IPW4C5FSH7EQ]
 Running shell script
sh: can't create 
/home/jenkins/workspace/_location-service_PR-2-head-RP4JKIYE4QYJREC2YOQQGNKQG5UC56YLZET3VDC2IPW4C5FSH7EQ@tmp/durable-de461dce/jenkins-log.txt:
 nonexistent directory


Since the node I am accessing in that step is a container I thought maybe it 
was a permissions issue. However I validated this wasn't the case by making 
that agent (node { label 'docker1' }} the top level agent and the pipeline runs 
fine. 


So my thought is that during the switch between agents/nodes it is expecting 
that directory to exist (it does create the workspace directory though, just 
not durable).


Any help would be appreciated.


Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/cf5d0491-00ac-4c41-860f-49f926b9d461%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to