Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tar file of archived outputs #40

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fmo-os-main-pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ targets.each {
utils.nix_build("${target}", 'archive')
}
}
stage("Archive ${target}") {
dir(FMO_PATH) {
utils.archive_artifacts("${target}", ['archive'])
}
}
}
}

Expand Down
26 changes: 16 additions & 10 deletions utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,29 @@ def run_rclone(String opts) {
"""
}

def archive_artifacts(String subdir) {
if (!subdir) {
println "Warning: skipping archive, subdir not set"
def archive_artifacts(String flakeref, ArrayList subdirs) {
String flakeref_trimmed = "${flakeref_trim(flakeref)}"
if (!subdirs) {
println "Warning: skipping archive, subdirs not set"
return
}
// 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}/"
// List paths to tar as a string
String pathTail = "/${flakeref_trimmed}/* "
String toTar = subdirs.join(pathTail) + pathTail
sh """
# tar is missing from Jenkins PATH
export PATH="$PATH:/run/current-system/sw/bin"
tar -cvf ${subdirs[0]}/${flakeref_trimmed}.tar ${toTar}
"""
for (dir in subdirs) {
run_rclone("copy -L ${dir}/ :webdav:/${env.ARTIFACTS_REMOTE_PATH}/")
}
String href="/artifacts/${env.ARTIFACTS_REMOTE_PATH}/"
currentBuild.description = "<a href=\"${href}\">📦 Artifacts</a>"
}

Expand Down Expand Up @@ -66,10 +77,6 @@ def nix_build(String flakeref, String subdir=null) {
// Store the build end time to job's environment
epoch_seconds = (int) (new Date().getTime() / 1000l)
env."END_${flakeref_trimmed}_${env.BUILD_TAG}" = epoch_seconds
// Archive possible build outputs from subdir directory
if (subdir) {
archive_artifacts(subdir)
}
} catch (InterruptedException e) {
// Do not continue pipeline execution on abort.
throw e
Expand Down Expand Up @@ -127,7 +134,6 @@ def sbomnix(String tool, String flakeref) {
csvcut vulns.csv --not-columns sortcol | csvlook -I >${outdir}/vulns.txt
"""
}
archive_artifacts("scs")
}

def find_img_relpath(String flakeref, String subdir) {
Expand Down
Loading