forked from cesarvr/Spring-Boot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
79 lines (61 loc) · 1.94 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
77
78
79
/*
assumes build and deployment configurations have been created beforehand as below:
oc new-build --binary=true --name=spring-demo-bake registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.3 --to=spring-demo
oc new-app --image-stream spring-demo --name=spring-demo-dev
oc expose dc spring-demo-dev
oc set env dc spring-demo-dev JAVA_OPTIONS="-Dmanagement.endpoints.jmx.exposure.include=health,info"
oc set probe dc spring-demo-dev --readiness --get-url=http://:8080/health
oc set probe dc spring-demo-dev --liveness --get-url=http://:8080/health
*/
def appName = "${params.APPLICATION_NAME}"
def PROXY = "${params.PROXY}"
def imageBuildConfig = appName
def deploymentConfig = appName
def PROXY_JVM_OPTIONS = "-DproxySet=true -DproxyHost=${PROXY} -DproxyPort=8080"
pipeline {
agent {
label 'maven'
}
stages {
stage('Creating Project ${appName}') {
steps {
echo "Creating Openshift Objects"
sh "echo creating objects for ${appName} && chmod +x ./jenkins/build.sh && ./jenkins/build.sh ${appName}"
}
}
stage("Running Test\'s") {
steps {
echo "Run unit tests"
sh "mvn ${PROXY_JVM_OPTIONS} surefire-report:report"
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Creating and Deploying Container') {
steps {
echo "Trigger image build"
script {
sh "mvn ${PROXY_JVM_OPTIONS} package"
sh "ls target/*.jar"
sh "oc start-build bc/${appName} --from-file=\$(ls target/*.jar) --follow"
}
}
post {
success {
archiveArtifacts artifacts: 'target/**.jar', fingerprint: true
}
}
}
stage('Deploy') {
steps {
script {
sh "oc rollout latest dc/${appName}"
sh "oc wait dc/${appName} --for condition=available"
}
}
}
}
}