如何在声明性管道中的 Jenkinsfile 中跨阶段存储和取消存储人工制品
How to stash and unstash artefacts across stages in a Jenkinsfile in declarative pipeline
我在带有声明管道的 Jenkinsfile 中有 2 个阶段
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'
}
}
prepare_build_artefacts.sh
接收跨阶段调用的 build.sh
的输出。
如何存储输出构建目录并在构建阶段之后的第二阶段取消存储?
请参阅下面的代码,这将帮助您存储和 unstash.Note 存储和取消存储步骤专为小文件使用而设计。对于大数据传输,使用外部工作区管理器插件,或使用外部存储库管理器,如 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'
}
}
我在带有声明管道的 Jenkinsfile 中有 2 个阶段
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'
}
}
prepare_build_artefacts.sh
接收跨阶段调用的 build.sh
的输出。
如何存储输出构建目录并在构建阶段之后的第二阶段取消存储?
请参阅下面的代码,这将帮助您存储和 unstash.Note 存储和取消存储步骤专为小文件使用而设计。对于大数据传输,使用外部工作区管理器插件,或使用外部存储库管理器,如 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'
}
}