Ran another test that seems to validate somewhat of what I said above. 
Instead of having a global agent I specified an agent per stage (2 stages)

In this situation the first agent created the workspace, checked out the 
code and the durable- directory existed.

When it got to the second stage and connected to the docker container it 
created the workspace but not the durable- directory but at the same time 
didn't complain about it like the above error message.


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

pipeline {
  agent none
  stages {

    stage('Build') {
      agent {
        kubernetes {
          label buildId()
          containerTemplate {
            name 'node'
            image 'node:8.9.4-alpine'
            ttyEnabled true
            command 'cat'
          }
        }
      }
      steps {
        sh "echo npm run build"
        sh "/bin/sleep 120"
        
        // stash build directory
        //stash includes: 'build/**', name: 'app'
      }
    }

    stage('Package') {
      agent { node { label 'docker1' } }
      options { skipDefaultCheckout() }
      steps {
        sh "/bin/sleep 120"
      }
    }
    
  }
}







On Thursday, March 8, 2018 at 1:19:31 PM UTC-8, Matthew Ceroni wrote:
>
> 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/49f8742c-0210-4850-abd3-adb7928dd076%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to