pipelineUtils/vars/buildStep.groovy
2024-02-01 02:10:31 -08:00

25 lines
571 B
Groovy

#!/usr/bin/env groovy
import groovy.transform.Field
@Field
Map defaults = [
saveArtifaces: false,
buildTest: 'Makefile',
buildCmd: 'make all'
]
def call(Map config = [:]) {
Map runConfig = defaults + config
if (runConfig.saveArtifacts) {
assert config.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.")
}
}