如何在声明管道中的Jenkinsfile中跨阶段隐藏和取消隐藏人工制品



我在一个Jenkinsfile中有两个阶段,该文件具有decarative管道

stage("Build_Stage") {
steps {
sh './build.sh 2>&1 ; test ${PIPESTATUS[0]} -eq 0'
// The output directory is ./build. How to stash this here
}
}
stage("Upload_Artefacts_Stage") {
steps {
// How to unstash the build directory which was stashed in Build_Stage
sh './prepare_build_artefacts.sh ios 2>&1 ; test ${PIPESTATUS[0]} -eq 0'
}
}

CCD_ 1接收跨级调用的CCD_ 2的输出。

如何将输出构建目录隐藏起来,并在构建阶段之后的第二阶段取消隐藏?

请参阅下面的代码,这些代码将帮助您隐藏和取消隐藏。请注意,隐藏和取消隐藏步骤是为小文件而设计的。对于大型数据传输,请使用外部工作区管理器插件,或使用外部存储库管理器,如Nexus或Artifactory

stage("Build_Stage") {
steps {
sh './build.sh 2>&1 ; test ${PIPESTATUS[0]} -eq 0'
// The output directory is ./build. How to stash this here
// Below method will stash build directory 
stash includes: "build/" , name: "Build_stash"
}
}
stage("Upload_Artefacts_Stage") {
steps {
// How to unstash the build directory which was stashed in Build_Stage
// Give path of the directory where you would like to unstash it.
dir("C:\Data\CI_Workspace\${env.JOB_NAME}")
{
unstash "Build_stash"
}
sh './prepare_build_artefacts.sh ios 2>&1 ; test ${PIPESTATUS[0]} -eq 0'
}
}

最新更新