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 flash script for each target artifacts #81

Closed
wants to merge 1 commit into from
Closed
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
45 changes: 44 additions & 1 deletion utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def run_rclone(String opts) {
}

def archive_artifacts(String subdir, String target="") {
//
// Create artifacts to webdev server.(Jenkins normal artifacts bypassed)
// Add flash script to every created/existing artifact target directory
//
if (!subdir) {
println "Warning: skipping archive, subdir not set"
return
Expand All @@ -39,7 +43,32 @@ def archive_artifacts(String subdir, String target="") {
println "Warning: skipping archive, ARTIFACTS_REMOTE_PATH not set"
return
}
run_rclone("copy -L ${subdir}/${target} :webdav:/${env.ARTIFACTS_REMOTE_PATH}/${target}")
// store flashscript in target directoy
def flashScript=find_flash_script()
if (target) {
run_rclone("copy -L ${subdir}/${target} :webdav:/${env.ARTIFACTS_REMOTE_PATH}/${target}")
if (!target.endsWith(".doc") && flashScript !="") {
println "Including flash script in artifacts for ${target}"
run_rclone("copy -L ${flashScript} :webdav:/${env.ARTIFACTS_REMOTE_PATH}/${target}")
}
else {
println "No flashscript found or target is .doc"
}
} else {
// operate in existing directories of subdir if target is empty
def targets = sh(script: "ls -d ${subdir}/*/", returnStdout: true).trim().split('\n')
for (dir in targets) {
def targetDir = dir.replace("${subdir}/", "")
run_rclone("copy -L ${dir} :webdav:/${env.ARTIFACTS_REMOTE_PATH}/${targetDir}")
if (!targetDir.endsWith(".doc") && flashScript !="") {
println "Including flash script in artifacts for ${targetDir}"
run_rclone("copy -L ${flashScript} :webdav:/${env.ARTIFACTS_REMOTE_PATH}/${targetDir}")
} else {
println "No flashscript found or target is .doc"
}

}
}
// Add a link to Artifacts on the build description if it isn't added yet
href = "/artifacts/${env.ARTIFACTS_REMOTE_PATH}/"
artifacts_anchor = "<a href=\"${href}\">📦 Artifacts</a>"
Expand Down Expand Up @@ -306,4 +335,18 @@ def ghaf_parallel_hw_test(String flakeref, String device_config, String testset=

return this


def find_flash_script() {
def flashScript=""
// jenkins workspace organization varies between builds
if (fileExists("ghaf/packages/flash/flash.sh")) {
flashScript = "ghaf/packages/flash/flash.sh"
} else if (fileExists("packages/flash/flash.sh")) {
flashScript = "packages/flash/flash.sh"
} else {
error("Error: Flash script not found in either predefined locations")
}
return flashScript
}

////////////////////////////////////////////////////////////////////////////////
Loading