Revamp stages and restructure project #1
6
src/com/thejimnicholson/Versioner.groovy
Normal file
6
src/com/thejimnicholson/Versioner.groovy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
class Versioner {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,24 +1,28 @@
|
|||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
void call(Map config = [:]) {
|
void call(Map config = [:], Closure body) {
|
||||||
Map defaults = [
|
Map defaults = [
|
||||||
saveArtifaces: false,
|
saveArtifaces: false,
|
||||||
buildTest: 'Makefile',
|
buildTest: 'Makefile',
|
||||||
buildCmd: 'make all'
|
buildCmd: 'make all',
|
||||||
|
stepName: 'Build'
|
||||||
]
|
]
|
||||||
Map runConfig = defaults + config
|
Map runConfig = defaults + config
|
||||||
if (runConfig.saveArtifacts) {
|
stage(runConfig.stepName) {
|
||||||
assert runConfig.artifacts : 'Error: saveArtifacts is set to true; must specify artifacts!'
|
if (runConfig.saveArtifacts) {
|
||||||
}
|
assert runConfig.artifacts : 'Error: saveArtifacts is set to true; must specify artifacts!'
|
||||||
if ( fileExists(runConfig.buildTest)) {
|
}
|
||||||
sh """
|
if ( fileExists(runConfig.buildTest)) {
|
||||||
${runConfig.buildCmd}
|
sh """
|
||||||
"""
|
${runConfig.buildCmd}
|
||||||
} else {
|
"""
|
||||||
error("ERROR: File ${runConfig.buildTest} does not exist in workspace.")
|
} else {
|
||||||
}
|
error("ERROR: File ${runConfig.buildTest} does not exist in workspace.")
|
||||||
if (runConfig.saveArtifacts) {
|
}
|
||||||
artifactsList = runConfig.artifacts.inspect().replaceAll('[\\[\\]\'\"]', '')
|
if (runConfig.saveArtifacts) {
|
||||||
archiveArtifacts artifacts: artifactsList, followSymlinks: false
|
artifactsList = runConfig.artifacts.inspect().replaceAll('[\\[\\]\'\"]', '')
|
||||||
|
archiveArtifacts artifacts: artifactsList, followSymlinks: false
|
||||||
|
}
|
||||||
|
body()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,13 @@
|
|||||||
#!/usr/bin/env groovy
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
void call() {
|
void call(Map config = [:], Closure body) {
|
||||||
checkout scm
|
Map defaults = [
|
||||||
|
stepName: 'Checkout',
|
||||||
|
useJobSCM: true
|
||||||
|
]
|
||||||
|
runDefaults = defaults + config
|
||||||
|
stage(runConfig.stepName) {
|
||||||
|
checkout scm
|
||||||
|
body()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,5 +10,14 @@ String call(Map config = [:]) {
|
|||||||
script: "git describe --tags --always --dirty=${runConfig.dirtyFlag}",
|
script: "git describe --tags --always --dirty=${runConfig.dirtyFlag}",
|
||||||
returnStdout: true
|
returnStdout: true
|
||||||
).trim()
|
).trim()
|
||||||
return gitTag
|
|
||||||
|
gitHash = sh(
|
||||||
|
script: 'git rev-parse --short HEAD',
|
||||||
|
returnStdout: true
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
runConfig.tag = gitTag
|
||||||
|
runConfig.hash = gitHash
|
||||||
|
|
||||||
|
return runConfig
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user