I have Jenkinsfile, Im trying to stash BuildApp and unstash it into other docker container to run npm test. but seems like it's missing node_modules, so npm test fails.
steps {
    dir("/var/jenkins_home") {
      unstash "app"
    }
    echo "Building app (CLOUD_ENV = ${env.CLOUD_ENV})"
    sh 'yarn install'
    stash name: "BuildApp", includes: "*"
    sh "ls -la ${pwd()}"
  }
That's where I'm trying to stash and I did debug with "ls -la ${pwd()}" and I see that node_modules are there but when unstash them
steps {
    dir("/var/jenkins_home") {
      unstash "BuildApp"
    }
    echo "Testing app (CLOUD_ENV = ${env.CLOUD_ENV})"
    // unstash 'builtApp'
    sh "ls -la ${pwd()}"
    sh 'npm test > test.out'
    archiveArtifacts artifacts: 'test.out', fingerprint: true
    stash name: "testApp", includes: "*"
  }
I did "ls -la ${pwd()}" and I can see that node_modules folder is not there.
Am I doing something wrong?
I guess that * only includes files in the current directory. In that case ** should do the trick since it also matches path separators.
Also in your code you unstash in a different directory than you execute ls. I don't see any reason for the dir command, so I suggest to remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With