This repository was archived by the owner on Mar 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
76 lines (74 loc) · 2.44 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def version = "latest"
def appName = env.APP_NAME
def currentProject
pipeline {
agent {
label 'maven'
}
stages {
stage('checkout') {
steps {
checkout scm
}
}
stage('clean') {
steps {
sh "mvn clean"
}
}
stage('Determine project & version') {
steps {
script {
version = sh returnStdout: true, script: 'mvn -q -Dexec.executable=echo -Dexec.args=\'${project.version}\' --non-recursive exec:exec'
echo "Current project version is ${version}"
openshift.withCluster() {
openshift.withProject() {
currentProject = openshift.project()
echo "Current project is ${currentProject}"
}
}
}
}
}
stage('Test/Packaging') {
steps {
sh "mvn package"
}
}
stage('Create Image Builder') {
when {
expression {
openshift.withCluster() {
openshift.withProject() {
return !openshift.selector("bc", appName).exists()
}
}
}
}
steps {
script {
openshift.withCluster() {
openshift.withProject() {
if(openshift.selector("bc", appName).exists()) {
openshift.selector("bc", appName).delete()
}
openshift.newBuild("--name=${appName}", "--strategy docker", "--binary=true", "--docker-image=fabric8/java-centos-openjdk8-jdk")
}
}
}
}
}
stage('Build Image') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
openshift.selector("bc", appName).startBuild("--from-dir=.", "--wait=true", "--follow")
openshift.tag("${currentProject}/${appName}:latest", "${currentProject}/${appName}:${version}")
}
}
}
}
}
}
}