Skip to content

Commit

Permalink
Simplify intended stash usage
Browse files Browse the repository at this point in the history
Signed-off-by: Henri Rosten <[email protected]>
  • Loading branch information
henrirosten committed Jun 25, 2024
1 parent d317412 commit 207825b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
15 changes: 1 addition & 14 deletions ghaf-pre-merge-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ pipeline {
)
script {
env.TARGET_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
env.STASH_REMOTE_PATH = "stash/${env.BUILD_TAG}-commit_${env.TARGET_COMMIT}"
}
}
}
Expand Down Expand Up @@ -138,11 +137,7 @@ pipeline {
steps {
dir(WORKDIR) {
script {
// Temporarily store the agx build result (image) to 'stash'.
// The stash is currently not used, but this is an example showing
// how to make the image available for HW-testing, without
// permanently archiving the build output to artifact storage.
utils.nix_build('.#packages.aarch64-linux.nvidia-jetson-orin-agx-debug', 'stash')
utils.nix_build('.#packages.aarch64-linux.nvidia-jetson-orin-agx-debug')
utils.nix_build('.#packages.aarch64-linux.nvidia-jetson-orin-nx-debug')
utils.nix_build('.#packages.aarch64-linux.doc')
}
Expand All @@ -151,14 +146,6 @@ pipeline {
}
}
post {
always {
script {
if(utils) {
// Remove temporary, stashed build results before exiting the pipeline
utils.purge_stash(env.STASH_REMOTE_PATH)
}
}
}
success {
script {
setGitHubPullRequestStatus(
Expand Down
27 changes: 8 additions & 19 deletions utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,15 @@ def archive_artifacts(String subdir) {
if (!subdir) {
println "Warning: skipping archive, subdir not set"
return
} else if (subdir == "stash") {
// 'stash' subdir is a special case indicating the artifacts under
// that directory are temporary, and will (might) be manually removed
// at the end of the pipeline. For that reason, no artifacts link
// will be set in the build description.
if (!env.STASH_REMOTE_PATH) {
println "Warning: skipping archive, STASH_REMOTE_PATH not set"
return
}
run_rclone("copy -L ${subdir}/ :webdav:/${env.STASH_REMOTE_PATH}/")
} else {
// All other subdirs are archived to env.ARTIFACTS_REMOTE_PATH
if (!env.ARTIFACTS_REMOTE_PATH) {
println "Warning: skipping archive, ARTIFACTS_REMOTE_PATH not set"
return
}
run_rclone("copy -L ${subdir}/ :webdav:/${env.ARTIFACTS_REMOTE_PATH}/")
href="/artifacts/${env.ARTIFACTS_REMOTE_PATH}/"
currentBuild.description = "<a href=\"${href}\">📦 Artifacts</a>"
}
// Archive artifacts to env.ARTIFACTS_REMOTE_PATH
if (!env.ARTIFACTS_REMOTE_PATH) {
println "Warning: skipping archive, ARTIFACTS_REMOTE_PATH not set"
return
}
run_rclone("copy -L ${subdir}/ :webdav:/${env.ARTIFACTS_REMOTE_PATH}/")
href="/artifacts/${env.ARTIFACTS_REMOTE_PATH}/"
currentBuild.description = "<a href=\"${href}\">📦 Artifacts</a>"
}

def purge_stash(String remote_path) {
Expand Down

0 comments on commit 207825b

Please sign in to comment.