pipelineUtils/vars/buildStep.groovy
Jim Nicholson b76d3f0fc5 Revamp stages and restructure project (#1)
Reviewed-on: #1
Co-authored-by: Jim Nicholson <thejimnicholson@gmail.com>
Co-committed-by: Jim Nicholson <thejimnicholson@gmail.com>
2024-02-08 02:22:19 +00:00

30 lines
920 B
Groovy

#!/usr/bin/env groovy
void call(Map config = [:], Closure body = { }) {
Map defaults = [
saveArtifaces: false,
buildTest: 'Makefile',
buildCmd: 'make all',
stepName: 'Build'
]
Map runConfig = defaults + config
stage(runConfig.stepName) {
printBanner(runConfig.stepName)
if (runConfig.saveArtifacts) {
assert runConfig.artifacts : 'Error: saveArtifacts is set to true; must specify artifacts!'
}
if ( fileExists(runConfig.buildTest)) {
sh """
${runConfig.buildCmd}
"""
} else {
error("ERROR: File ${runConfig.buildTest} does not exist in workspace.")
}
if (runConfig.saveArtifacts) {
artifactsList = runConfig.artifacts.join(',')
archiveArtifacts artifacts: artifactsList, followSymlinks: false
}
body()
}
}