1

I wrote two steps in Jenkinsfile to save and restore artifacts:

def buildCache    = 'packages-deps.tgz'
//...
stage('Restore cache') {
  unarchive mapping: [(buildCache): buildCache]
  sh "[ -a ${buildCache}  ] && tar xf ${buildCache}"
}

stage('Cache development libraries') {
  sh 'tar czf packages-deps.tgz _build node_modules deps'
  archiveArtifacts buildCache
}

It's 100% that artifacts was build and stored: I can see relevant messages in the build log

+ tar czf packages-deps.tgz _build node_modules deps
[Pipeline] step
Archiving artifacts

And file itself in the branch build index page http://d.pr/i/AHBE.jpg

But the "Restore cache" step is failing with the following error: hudson.AbortException: no artifacts to unarchive in packages-deps.tgz

I even tried wildcard unarchive mapping: ['**/.*': '.'] but that yielded the same result: hudson.AbortException: no artifacts to unarchive in **/.*

Update: my goal is to copy compiler artifacts and fetched dependencies from build to build to speed up the execution time. For builds of all branches. We are using only one node so far.

lessless
  • 866
  • 10
  • 27
  • I think you need to use [`stash` and `unstash`](https://jenkins.io/doc/pipeline/steps/workflow-basic-steps/#stash-stash-some-files-to-be-used-later-in-the-build) for the purpose you are doing... – khmarbaise Jan 27 '17 at 22:30
  • I updated the post to reflect that artifacts should be copied between builds, not between nodes in a single build. – lessless Jan 28 '17 at 02:49
  • The simplest solution for this is to keep the workspace where you should have the local cache inside the workspace ? – khmarbaise Jan 28 '17 at 14:44
  • And If you are running on the same node you will always keep the cache so I don't see any need to handle this yourself.. – khmarbaise Jan 28 '17 at 14:57
  • 1
    How can single workspace be shared across parallel builds? – lessless Jan 29 '17 at 05:41

0 Answers0