-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
46 lines (41 loc) · 1.07 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
pipeline {
agent any
environment {
AWS_REGION = 'eu-central-1'
}
stages {
stage('SonarQube analysis') {
agent {
docker { image 'sonarsource/sonar-scanner-cli:latest' }
}
steps {
withSonarQubeEnv('SonarCloud') {
sh 'sonar-scanner'
}
}
}
stage('Build image') {
steps {
script {
app = docker.build("ekungurov/myapp")
docker.withRegistry('https://registry.hub.docker.com', 'docker_creds') {
if (env.IMAGE_TAG != "latest") {
app.push("${env.IMAGE_TAG}")
}
app.push("latest")
}
}
}
}
stage('Deploy to eks') {
steps {
withCredentials([usernamePassword(credentialsId: 'aws-token', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY')]) {
withKubeConfig([credentialsId: 'kube-config-file']) {
sh "sed -i 's/__TAG__/${env.IMAGE_TAG}/g' k8s/deployment.yml"
sh 'kubectl apply -f k8s/'
}
}
}
}
}
}