-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsfile.groovy
72 lines (57 loc) · 1.77 KB
/
jenkinsfile.groovy
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
63
64
65
66
67
68
69
70
71
72
def isRelease() {
return env.IS_RELEASE_JOB == "true"
}
def readVersion(){
def version = sh returnStdout: true, script: 'cat version.txt'
return version
}
def getUpdatedVersion(String versionType, String currentVersion){
def split = currentVersion.split('\\.')
split = [split[0], split[1], split[2].split('-')[0]]
switch (versionType){
case "minor.minor":
split[2] = Integer.parseInt(split[2]) + 1
break
case "minor":
split[1] = Integer.parseInt(split[1]) + 1
break;
case "major":
split[0] = Integer.parseInt(split[0]) + 1
break;
}
def version = split.join('.')
if(!isRelease()){
version = "${version}-SNAPSHOT"
}
return version
}
node("JenkinsOnDemand") {
def organization = 'Provectus'
def repository = 'reqstore_cpp'
def accessTokenId = 'HydroRobot_AccessToken'
stage("Checkout") {
def branches = (isRelease()) ? [[name: env.BRANCH_NAME]] : scm.branches
checkout([
$class: 'GitSCM',
branches: branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: [[$class: 'CloneOption', noTags: false, shallow: false, depth: 0, reference: '']],
userRemoteConfigs: scm.userRemoteConfigs,
])
}
stage('Build image') {
env.LAST_VERSION = readVersion()
env.NEW_VERSION = env.LAST_VERSION
env.DOCKER_IMAGE = "hydrosphere/${repository}:${env.NEW_VERSION}"
sh "docker build -t ${env.DOCKER_IMAGE} ."
}
stage('test') {
sh 'docker images'
sh "cd scalaClient && sbt test"
}
if (isRelease()) {
stage("Publish docker") {
sh "docker push ${env.DOCKER_IMAGE}"
}
}
}