forked from redhat-cop/container-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
69 lines (63 loc) · 2.29 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
library identifier: "[email protected]",
retriever: modernSCM(
[
$class: "GitSCMSource",
remote: "https://github.com/redhat-cop/pipeline-library.git"
]
)
// URL and Ref to the Spring Boot application
appSourceUrl = "https://github.com/redhat-cop/spring-rest.git"
appSourceRef = "master"
// Folder containing the Spring Boot application
appFolder = "spring-rest"
// Folder containing the Helm pipeline
helmFolder = "basic-helm-spring-boot"
// The name you want to give your Spring Boot application
// Each resource related to your app will be given this name
appName = "my-app"
pipeline {
agent { label "jenkins-agent-helm" }
stages {
stage("Checkout") {
steps {
// This creates a separate folder to clone the Spring Boot app to
sh "mkdir ${appFolder}"
dir(appFolder) {
git url: "${appSourceUrl}", branch: "${appSourceRef}"
}
}
}
stage("Get Version from POM") {
steps {
script {
dir(appFolder) {
tag = readMavenPom().getVersion()
}
}
}
}
stage("S2I Build") {
steps {
// This installs or upgrades the spring-boot-build Helm chart.
// It creates or updates your application's BuildConfig and ImageStream
dir(helmFolder) {
sh "helm upgrade --install ${appName}-build .helm/spring-boot-build --set name=${appName} --set tag=${tag}"
}
// This uploads your application's source code and performs a binary build in OpenShift
dir(appFolder) {
binaryBuild(buildConfigName: appName, buildFromPath: ".")
}
}
}
stage("Deploy") {
steps {
// This installs or upgrades the spring-boot Helm chart
// It creates or updates your application's Kubernetes resources
// It also waits until the readiness probe returns successfully
dir(helmFolder) {
sh "helm upgrade --install ${appName} .helm/spring-boot --set tag=${tag} --wait"
}
}
}
}
}