问题
I used the ubundu as a master machine of jenkins server and configured windows machine as the slave. I tried to stash and unstash a file from master to slave's worksapce but it is not unstashed.
node('slave') {
node('master'){
stash includes: "file.tgz" name: "master-stash"
}
unstash "master-stash"
bat "ls"
}
Output:
[Pipeline] node
Running on master in /var/lib/jenkins/workspace/testing
[Pipeline] {
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
[Pipeline] // node
[Pipeline] unstash
The file can be stashed from the master, but it is not unstashed in the slave's workspace.
jenkins: 2.35
回答1:
I think that you should use:
unstash name: 'stash_name'
I'm using Jenkins at 2.47 version and it works for me. One thing here is that, if you include "rootFolder/file.tgz", your unstash will gives you the entire path with the file. If you want to get just the file and put it on the current directory, you should use:
dir('path to file'){
stash name: 'my_stash' includes:'file.something'
}
unstash name:'my_stash'
sh 'ls'
The output of sh'ls .'
will shows you "file.something" and the other files from the folder that you makes unstash.
回答2:
I resolved the stash ans unstash problem by adding root folder in the stash includes. I don't know why it is not unstash a single file, but it can unstash a root folder with file.
node('slave') {
node('master'){
stash includes: "rootFolder/file.tgz" name: "master-stash"
}
unstash "master-stash"
bat "ls"
}
The unstash file can be get from rootFolder/file.tgz of current workspace.
来源:https://stackoverflow.com/questions/42508119/file-not-unstash-in-slave-machine-of-jenkins-server