我试图写一个" stash_files"和" unstash_files"我的共享库类中的方法。
stash
仅适用于工作区吗?file.txt
复制到工作区?stash
获取了file_name和一个stash_name(稍后会被取消),它在共享库中是如何工作的? Jenkinsfile
:
@Library('Utils')
import org.jenkins.Utils
utils = new Utils(steps)
node() {
stage('first'){
utils.doit("file.txt")
}}
共享库:
package src.org.jenkins
class Utils implements Serializable {
def steps
Utils(steps) {
this.steps = steps
}
def doit(filename){
this.steps.sh "echo hii > /tmp/$filename"
this.stash_file(filename)
}
def stash_files(filename){
this.steps.stash filename
}
def unstash_files(filename){
this.steps.unstash filename
答案 0 :(得分:0)
这对我有用:
def stash_file(file_name, name){
this.steps.stash ('includes': file_name, 'name': name)
}
def unstash_file(name){
this.steps.unstash name
}