-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
49 lines (46 loc) · 1.91 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
pipeline {
agent any
stages {
stage('Build Docker Image') {
steps {
sh './mvnw package -Pprod verify -DskipTests jib:dockerBuild'
}
post {
success {
echo "Docker Image has been built"
}
}
}
stage('Publish Docker Image to Azure Container Registry') {
steps {
withCredentials([string(credentialsId: 'EKS-Region', variable: 'REGION'), string(credentialsId: 'Registry-Name', variable: 'REGISTRY_NAME')]) {
sh 'docker login -u AWS -p $(aws ecr get-login-password --region $REGION) $REGISTRY_NAME'
sh 'echo $REGISTRY_NAME"/makeathon/discourse:${BUILD_NUMBER}"'
sh 'docker tag discourse:latest $REGISTRY_NAME"/makeathon/discourse:${BUILD_NUMBER}"'
sh 'docker push $REGISTRY_NAME"/makeathon/discourse:${BUILD_NUMBER}"'
}
}
post {
success {
echo "Published Docker Image to Azure Container Registry"
}
}
}
stage('Deploy Application in AKS') {
steps {
sh 'kubectl apply -f kubernetes/deployment.yml'
sh 'kubectl apply -f kubernetes/service.yml'
sh 'kubectl apply -f kubernetes/ingress.yml'
sh 'kubectl apply -f kubernetes/autoscale.yml'
withCredentials([string(credentialsId: 'Registry-Name', variable: 'REGISTRY_NAME')]) {
sh 'kubectl set image deployment/discourse discourse=$REGISTRY_NAME"/makethon/discourse:${BUILD_NUMBER}" -n makethon'
}
}
post {
success {
echo "Deployed to AKS"
}
}
}
}
}