Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins stash is not stashing all files and folders

Tags:

jenkins

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?

like image 945
Arsen Avatar asked Sep 14 '18 17:09

Arsen


1 Answers

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.

like image 124
Michael Avatar answered Oct 21 '22 07:10

Michael