-
Notifications
You must be signed in to change notification settings - Fork 2
/
nginx-green-Jenkinsfile
40 lines (40 loc) · 1.4 KB
/
nginx-green-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
pipeline {
agent any
stages {
stage('Git Clone Source Repositoty') {
steps {
git branch: 'main',
url: 'https://github.com/breinerHenrique/terraform-aws-eks-lab.git'
}
}
stage('Build Image') {
steps {
script {
dockerapp = docker.build("breinerhenrique/eks-lab-nginx-green:${env.BUILD_ID}", '-f source_code/green/dockerfile .')
}
}
}
stage('Push Image') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub') {
dockerapp.push('latest')
dockerapp.push("${env.BUILD_ID}")
}
}
}
}
stage('Deploy on AWS EKS') {
environment {
tag_version = "${env.BUILD_ID}"
}
steps {
script {
sh 'sed -i "s/{{tag}}/$tag_version/g" ./k8s/api/deployment-green.yaml' /*insere a tag no arquivo de deployment*/
sh 'cat ./k8s/api/deployment-green.yaml' /*exibe o conteudo para verificar se alterou*/
sh 'kubectl apply -f k8s/api/deployment-green.yaml -n api-services'
}
}
}
}
}