-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
49 lines (43 loc) · 1.3 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
node {
def app
def prod
def prodDockerfile = 'Dockerfile.prod'
stage('Clone repository') {
checkout scm
}
stage('Build image') {
app = docker.build("dev-image")
prod = docker.build("agmeteor/conway-game", "-f ${prodDockerfile} .")
}
withEnv(["HOME=."]) {
stage('Linting') {
app.inside {
sh 'yarn'
sh 'yarn lint'
}
}
}
withEnv(["HOME=.", "CI=true"]) {
stage('Testing') {
app.inside {
sh 'yarn'
sh 'yarn test'
}
}
}
stage('Push image') {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhubCreds') {
prod.push("${env.BUILD_NUMBER}")
}
}
stage('Deploy') {
withAWS(region:'us-east-2', credentials:'aws-creds') {
withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
sh("chmod +x updateGreenTag.sh")
sh("./updateGreenTag.sh ${env.BUILD_NUMBER}")
sh("kubectl --kubeconfig $KUBECONFIG apply -f k8s/deployment.yaml -f k8s/service.yaml")
sh("kubectl --kubeconfig $KUBECONFIG apply -f k8s/dep-green.yaml -f k8s/service-green.yaml")
}
}
}
}