forked from apache/incubator-kie-kogito-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
120 lines (112 loc) · 4.26 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@Library('jenkins-pipeline-shared-libraries')_
def changeAuthor = env.ghprbPullAuthorLogin ?: CHANGE_AUTHOR
def changeBranch = env.ghprbSourceBranch ?: CHANGE_BRANCH
def changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET
IMAGES = ["kogito-quarkus-ubi8",
"kogito-quarkus-jvm-ubi8",
"kogito-quarkus-ubi8-s2i",
"kogito-springboot-ubi8",
"kogito-springboot-ubi8-s2i",
"kogito-data-index",
"kogito-jobs-service",
"kogito-management-console"]
pipeline{
agent { label 'kogito-image-slave && !master'}
tools {
jdk 'kie-jdk11'
}
environment {
JAVA_HOME = "${GRAALVM_HOME}"
}
stages{
stage('Initialization'){
steps{
script{
cleanWorkspaces()
// Set the mirror url only if exist
if (env.MAVEN_MIRROR_REPOSITORY != null
&& env.MAVEN_MIRROR_REPOSITORY != ''){
env.MAVEN_MIRROR_URL = env.MAVEN_MIRROR_REPOSITORY
}
githubscm.checkoutIfExists('kogito-images', changeAuthor, changeBranch, 'kiegroup', changeTarget, true)
}
sh "docker rm -f \$(docker ps -a -q) || date"
sh "docker rmi -f \$(docker images -q) || date"
}
}
stage('Validate CeKit Image and Modules descriptors'){
steps {
sh """
curl -Ls https://github.com/kiegroup/kie-cloud-tools/releases/download/1.0-SNAPSHOT/cekit-image-validator-runner.tgz --output cekit-image-validator-runner.tgz
tar -xzvf cekit-image-validator-runner.tgz
chmod +x cekit-image-validator-runner
"""
sh "./cekit-image-validator-runner modules/"
sh """
./cekit-image-validator-runner image.yaml
./cekit-image-validator-runner kogito-data-index-overrides.yaml
./cekit-image-validator-runner kogito-jobs-service-overrides.yaml
./cekit-image-validator-runner kogito-management-console-overrides.yaml
./cekit-image-validator-runner kogito-quarkus-jvm-overrides.yaml
./cekit-image-validator-runner kogito-quarkus-overrides.yaml
./cekit-image-validator-runner kogito-quarkus-s2i-overrides.yaml
./cekit-image-validator-runner kogito-springboot-overrides.yaml
./cekit-image-validator-runner kogito-springboot-s2i-overrides.yaml
"""
}
}
stage('Prepare offline kogito-examples'){
steps{
sh "make clone-repos"
}
}
stage('Build and Test Images'){
steps{
script {
build_stages = [:]
IMAGES.each{ image -> build_stages["${image}"] = {
createWorkspace("$image")
copyWorkspace("$image")
dir(getWorkspacePath("$image")){
try{
sh "make ${image}"
}
finally{
junit 'target/test/results/*.xml'
}
}
}
}
parallel build_stages
}
}
}
stage('Finishing'){
steps{
sh "docker rmi -f \$(docker images -q) || date"
}
}
}
post{
always{
script{
cleanWorkspaces()
}
}
}
}
void createWorkspace(String image){
sh "mkdir -p ${getWorkspacePath(image)}"
}
void copyWorkspace(String image){
sh "rsync -av --progress . ${getWorkspacePath(image)} --exclude workspaces"
}
void cleanWorkspaces(){
sh "rm -rf ${getWorkspacesPath()}"
}
String getWorkspacesPath(){
return "${WORKSPACE}/workspaces"
}
String getWorkspacePath(String image){
return "${getWorkspacesPath()}/${image}"
}