-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
96 lines (83 loc) · 3.79 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
#!/usr/bin/env groovy
def microservices = 'comment, rest, session, user, auth, gateway'.split(', ')
pipeline {
agent any
tools {go "recent go"}
stages {
stage('Initialize') {
steps {
script {
sh "sudo cp /home/kayros/backend/config/config.yaml ./config/"
stage('Test') {
script {
//sh 'go test ./... -coverprofile=cover.out'
}
}
stage('Code Analysis') {
script {
// sh 'make easyjs'
// sh '/home/kayros/go/bin/golangci-lint run'
}
}
for (int i = 0; i < microservices.length; i++) {
def currentChange
def externalChange
for (change in currentBuild.changeSets) {
for (entry in change.getItems()) {
for (file in entry.getAffectedFiles()) {
if (file.getPath() =~ "${microservices[i]}") {
currentChange = 'true'
}
}
}
}
for (service in microservices) {
for (change in currentBuild.changeSets) {
for (entry in change.getItems()) {
for (file in entry.getAffectedFiles()) {
if (file.getPath().contains(service)) {
externalChange = 'true'
}
}
}
}
}
if (currentChange || !externalChange) {
stage("Build Microservice: ${microservices[i]}") {
script {
// sh "sudo cp /home/kayros/backend/config/config.yaml ./config/"
// sh "sudo docker build -t resto-${microservices[i]}-service:latest -f ./integration/microservices/${microservices[i]}/Dockerfile ."
def service = microservices[i]
if (microservices[i] != 'gateway') {
service = "${microservices[i]}-grpc"
}
sh "sudo docker-compose -f ./integration/prod-compose/docker-compose.yaml up -d --no-deps --build ${service}"
}
}
}
}
// if (params.FULL_BUILD && params.FULL_BUILD == true) {
// stage("Full Project Build") {
// script {
// sh "sudo docker-compose -f ./integration/prod-compose/docker-compose.yaml up -d --no-deps --build"
// }
// }
// }
// for (int i = 0; i < microservices.length; i++) {
// stage("Push Microservice: ${microservices[i]}") {
// script {
// def localImage = "resto-${microservices[i]}-service:latest"
// def repositoryName = "kayrosteam/${localImage}"
// sh "docker tag ${localImage} ${repositoryName} "
// docker.withRegistry("", "dockerhub-credentials") {
// def image = docker.image("${repositoryName}");
// image.push()
// }
// }
// }
// }
}
}
}
}
}