29 lines
766 B
Groovy
29 lines
766 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 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.inspect().replaceAll('\\[\\]','')
|
|
archiveArtifacts artifacts: artifactsList, followSymlinks: false
|
|
}
|
|
}
|