This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
61 lines (56 loc) · 1.55 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
/*
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.PROJECT_NAME}"
def imageBuildConfig = appName
def deploymentConfig = appName
pipeline {
agent {
label 'maven'
}
stages {
stage('Run unit tests') {
steps {
echo "Run unit tests"
sh 'mvn test'
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Build') {
steps {
echo "Build artifact"
sh 'mvn package'
echo "Trigger image build"
script {
openshift.withCluster() {
openshift.selector("bc", imageBuildConfig).startBuild("--from-file=target/ROOT.jar", "--wait")
}
}
}
post {
success {
archiveArtifacts artifacts: 'target/**.jar', fingerprint: true
}
}
}
stage('Deploy') {
steps {
script {
openshift.withCluster() {
openshift.selector("dc", deploymentConfig).rollout()
}
}
}
}
}
}