-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
52 lines (43 loc) · 1.26 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
pipeline {
agent any
environment {
VERSION_TYPE = getTypeOfVersion(env.BRANCH_NAME)
CONFIGURATION = getConfiguration(env.BRANCH_NAME)
}
stages {
stage('Build & Publish Docker') {
steps {
script {
def descriptor = readDescriptor()
def mType=getTypeOfVersion(env.BRANCH_NAME)
def testsuite = docker.build(descriptor.docker_image_name + ":${mType}" + descriptor.docker_image_version, "--no-cache .")
testsuite.tag("${mType}latest")
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub-emmanuelmathot') {
testsuite.push("${mType}" + descriptor.docker_image_version)
testsuite.push("${mType}latest")
}
}
}
}
}
}
def getTypeOfVersion(branchName) {
def matcher = (branchName =~ /master/)
if (matcher.matches())
return ""
return "dev"
}
def getConfiguration(branchName) {
def matcher = (branchName =~ /master/)
if (matcher.matches())
return "Release"
return "Debug"
}
def readDescriptor (){
return readYaml(file: 'build.yml')
}
def getVersionFromCsProj (csProjFilePath){
def file = readFile(csProjFilePath)
def xml = new XmlSlurper().parseText(file)
return xml.PropertyGroup.Version[0].text()
}