forked from shamil/mkimage-server
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJenkinsfile
62 lines (53 loc) · 1.5 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
node("build-docker") {
try {
stage('clone') {
/* Let's make sure we have the repository cloned to our workspace */
checkout scm
currentBuild.displayName = ""
}
withCredentials([
usernamePassword(credentialsId: 'builder', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASSWORD'),
file(credentialsId: 'npmrc', variable: 'NPM_CONFIG_USERCONFIG')
]) {
runBuildScripts()
}
}
catch (e) {
echo 'failed'
echo 'Exception: ' + e.toString()
throw e
}
finally {
def currentResult = currentBuild.result ?: 'SUCCESS'
if (currentResult == 'UNSTABLE') {
echo 'Build is unstable!'
}
def previousResult = currentBuild.previousBuild?.result
if (previousResult != null && previousResult != currentResult) {
echo 'State of the Pipeline has changed!'
}
echo 'Deleting directory...'
deleteDir()
}
}
def runBuildScripts() {
def buildSteps = findFiles(glob: ".build/*")
buildSteps.each { f ->
def filename = f.getName()
def stageName = getStageName(filename);
if (stageName) {
stage("${stageName}") {
sh ".build/${filename}"
if (fileExists(".${stageName}.tmp")) {
def info = readFile ".${stageName}.tmp"
currentBuild.displayName += "${info} "
}
}
}
}
}
@NonCPS
def getStageName(filename) {
def match = (filename =~ /.*(?!00)[0-9]{2}-(.+)\.sh/)
return match.matches()? match[0][1] : null
}