问题
I'm trying to setup Jenkins pipeline that compiles some node/grunt stuff, makes and RPM out of this and upload that RPM to desired repo. Somehow i have difficulties passing files between steps. So in the 'RPM upload stage' generated RPM is not visible and cannot be uploaded.
pipeline {
agent none
stages {
stage('Checkout') {
agent { label 'master' }
steps {
checkout(...)
}
}
stage('Build') {
agent { docker {
image 'custome-nodejs:4'
reuseNode true }
}
steps {
sh 'npm install'
sh "./build.sh build"
stash includes: '*.rpm', name: "rpms"
}
}
stage('RPM upload') {
agent { label 'master' }
steps {
unstash "rpms"
sh "./build.sh upload"
}
}
}
}
Relevant output
[Pipeline] stash
Stashed 1 file(s)
[Pipeline] }
...
[Pipeline] unstash
[Pipeline] sh
We see that exactly one file is stashed as expected, but no files are unstashed in the next step.
Could someone explain why? And how to fix it?
回答1:
I think i understood a problem. Which consist of two things.
1) bug in the build script deleted the RPM file. so it was not visible later. 2) I do not need stashing here, since we are in the 'declarative pipeline' using agents and not nodes. And stashing is needed on crossing nodes (Something similar i've read). Also unstash maybe worked here, despite the misleading message. And this
[Pipeline] unstash
maybe unstashed the file. How ever it was present here. and was deleted by the mentioned bug just after this in next step.
来源:https://stackoverflow.com/questions/43942073/unstash-is-not-putting-anything-in-the-next-step-of-jenkins-pipeline