Revamp stages and restructure project #1
@ -1,6 +1,9 @@
|
||||
{
|
||||
"extends": "recommended",
|
||||
"rules": {
|
||||
"DuplicateStringLiteral": {
|
||||
"enabled": false
|
||||
},
|
||||
"Indentation": {
|
||||
"enabled": false
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
@ -1,12 +1,15 @@
|
||||
#!/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
|
||||
stage(runConfig.stepName) {
|
||||
printBanner(runConfig.stepName)
|
||||
if (runConfig.saveArtifacts) {
|
||||
assert runConfig.artifacts : 'Error: saveArtifacts is set to true; must specify artifacts!'
|
||||
}
|
||||
@ -18,7 +21,9 @@ void call(Map config = [:]) {
|
||||
error("ERROR: File ${runConfig.buildTest} does not exist in workspace.")
|
||||
}
|
||||
if (runConfig.saveArtifacts) {
|
||||
artifactsList = runConfig.artifacts.inspect().replaceAll('[\\[\\]\'\"]', '')
|
||||
artifactsList = runConfig.artifacts.join(',')
|
||||
archiveArtifacts artifacts: artifactsList, followSymlinks: false
|
||||
}
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,16 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
void call() {
|
||||
void call(Map config = [:], Closure body = { }) {
|
||||
Map defaults = [
|
||||
stepName: 'Checkout',
|
||||
useJobSCM: true
|
||||
]
|
||||
runConfig = defaults + config
|
||||
stage(runConfig.stepName) {
|
||||
printBanner(runConfig.stepName)
|
||||
if (runConfig.useJobSCM) {
|
||||
checkout scm
|
||||
}
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,33 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
void call(Map config = [:]) {
|
||||
void call(Map config = [:], Closure body = { }) {
|
||||
Map defaults = [
|
||||
name: env.BUILD_TAG,
|
||||
archiveCmd: 'tar zcvf',
|
||||
archiveCmd: 'tar',
|
||||
archiveParams: 'zcvf',
|
||||
extension: 'tgz',
|
||||
artifacts: []
|
||||
artifacts: [],
|
||||
stepName: 'Package',
|
||||
separator: '-'
|
||||
]
|
||||
|
||||
Map runConfig = defaults + config
|
||||
|
||||
String archiveName = "${runConfig.name}-${runConfig.tag}.${runConfig.extension}"
|
||||
|
||||
stage(runConfig.stepName) {
|
||||
printBanner(runConfig.stepName)
|
||||
if (runConfig.artifacts.size() < 1) {
|
||||
assert runConfig.artifacts : 'Error: No named artifacts to package!'
|
||||
}
|
||||
archiveName = runConfig.name + runConfig.separator + runConfig.tag + runConfig.separator + runConfig.extension
|
||||
echo "Will tag result as: ${archiveName}"
|
||||
|
||||
sh """
|
||||
${runConfig.archiveCmd} ${archiveName} ${runConfig.artifacts.join(' ')}
|
||||
if command -v "${runConfig.archiveCmd}"; then
|
||||
${runConfig.archiveCmd} ${runConfig.archiveParams} ${archiveName} ${runConfig.artifacts.join(' ')}
|
||||
else
|
||||
echo "Error: ${runConfig.archiveCmd} is not a valid executable!"
|
||||
exit 2
|
||||
fi
|
||||
"""
|
||||
archiveArtifacts artifacts: archiveName, followSymlinks: false
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
28
vars/printBanner.groovy
Normal file
28
vars/printBanner.groovy
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
void call(String stepName) {
|
||||
red = '\033[31m'
|
||||
blue = '\033[34m'
|
||||
normal = '\033[0m'
|
||||
|
||||
stepBanner = "║ $blue$stepName$red ║"
|
||||
bannerWidth = stepName.length() + 6
|
||||
|
||||
top = '╔' + ('═' * bannerWidth) + '╗'
|
||||
bottom = '╚' + ('═' * bannerWidth) + '╝'
|
||||
ansiColor('xterm') {
|
||||
echo "$red$top\n$stepBanner\n$bottom$normal"
|
||||
}
|
||||
}
|
||||
|
||||
// fg_black = '\x1b[30m'
|
||||
// fg_red = "\x1b[31m"
|
||||
// fg_green = "\x1b[32m"
|
||||
// fg_yellow = "\x1b[33m"
|
||||
// fg_blue = "\x1b[34m"
|
||||
// fg_magenta = "\x1b[35m"
|
||||
// fg_cyan = "\x1b[36m"
|
||||
// fg_white = "\x1b[37m"
|
||||
// fg_default = "\x1b39m"
|
||||
// fg_reset = "\x1b[0m"
|
||||
|
||||
// ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬
|
||||
12
vars/publishStep.groovy
Normal file
12
vars/publishStep.groovy
Normal file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
void call(Map config = [:], Closure body = { }) {
|
||||
Map defaults = [
|
||||
stepName: 'Publish'
|
||||
]
|
||||
runConfig = defaults + config
|
||||
stage(runConfig.stepName) {
|
||||
printBanner(runConfig.stepName)
|
||||
body()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user