forked from apache/incubator-kie-kogito-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-Nightly
150 lines (145 loc) · 6.8 KB
/
Jenkinsfile-Nightly
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//Checks master branch for updates every day
//If found triggers the pipeline,
//The pipeline is set to run between 12:00AM - 3:00AM UTC
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 'jenkins-slave'}
triggers{
pollSCM(
scmpoll_spec: '@midnight',
ignorePostCommitHooks: true
)
}
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
}
}
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('Update Artifacts'){
steps{
sh "python3 scripts/update-maven-information.py"
}
}
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('Tagging'){
steps{
sh """
docker tag quay.io/kiegroup/kogito-quarkus-ubi8:latest quay.io/kiegroup/kogito-quarkus-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-quarkus-jvm-ubi8:latest quay.io/kiegroup/kogito-quarkus-jvm-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-quarkus-ubi8-s2i:latest quay.io/kiegroup/kogito-quarkus-ubi8-s2i-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-springboot-ubi8:latest quay.io/kiegroup/kogito-springboot-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-springboot-ubi8-s2i:latest quay.io/kiegroup/kogito-springboot-ubi8-s2i-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-data-index:latest quay.io/kiegroup/kogito-data-index-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-jobs-service:latest quay.io/kiegroup/kogito-jobs-service-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker tag quay.io/kiegroup/kogito-management-console:latest quay.io/kiegroup/kogito-management-console-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
"""
}
}
stage('Pushing'){
steps{
withDockerRegistry([ credentialsId: "quay", url: "https://quay.io" ]){
sh """
docker push quay.io/kiegroup/kogito-quarkus-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-quarkus-jvm-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-quarkus-ubi8-s2i-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-springboot-ubi8-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-springboot-ubi8-s2i-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-data-index-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-jobs-service-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
docker push quay.io/kiegroup/kogito-management-console-nightly:\$(echo \${GIT_COMMIT} | cut -c1-7)
"""
}
}
}
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}"
}