Some new stuff to try
This commit is contained in:
parent
1a1d694001
commit
cea3844edf
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
|
||||
|
||||
void call(Map config = [:]) {
|
||||
void call(Map config = [:], Closure body) {
|
||||
Map defaults = [
|
||||
saveArtifaces: false,
|
||||
buildTest: 'Makefile',
|
||||
buildCmd: 'make all'
|
||||
buildCmd: 'make all',
|
||||
stepName: 'Build'
|
||||
]
|
||||
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
|
||||
stage(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.inspect().replaceAll('[\\[\\]\'\"]', '')
|
||||
archiveArtifacts artifacts: artifactsList, followSymlinks: false
|
||||
}
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
void call() {
|
||||
checkout scm
|
||||
void call(Map config = [:], Closure body) {
|
||||
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}",
|
||||
returnStdout: true
|
||||
).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