Repository navigation
Expand file tree
/
Copy pathJenkinsfile
More file actions
67 lines (66 loc) · 2.13 KB
/
Copy pathJenkinsfile
File metadata and controls
67 lines (66 loc) · 2.13 KB
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
pipeline {
agent none
environment {
ENV_DOCKER = credentials('dockerhub')
DOCKERIMAGE = "dogistan/devopslab"
EKS_CLUSTER_NAME = "hilarious-painting-1661434301"
SONAR_TOKEN = credentials('sonar-token')
}
stages {
stage('build') {
agent {
docker { image 'openjdk:11-jdk' }
}
steps {
sh 'chmod +x gradlew && ./gradlew build jacocoTestReport'
stash includes: 'build/**/*', name: 'build'
}
}
stage('sonarqube') {
agent {
docker { image 'sonarsource/sonar-scanner-cli:latest' }
}
steps {
unstash 'build'
sh 'sonar-scanner'
}
}
stage('docker build') {
steps {
script {
echo "building image"
dockerImage = docker.build("dogistan/devopslab:${env.BUILD_NUMBER}")
}
}
}
stage('docker push') {
steps {
script {
echo "uploading image"
docker.withRegistry('https://registry.hub.docker.com/','dockerhub') {
dockerImage.push("${env.BUILD_NUMBER}")
dockerImage.push("latest")
}
}
}
}
stage('Deploy App') {
agent {
docker {
image 'jshimko/kube-tools-aws:3.8.1'
args '-u root --privileged'
}
}
steps {
echo 'Deploying to kubernetes'
withAWS(credentials:'aws-credentials') {
sh 'aws eks update-kubeconfig --name hilarious-painting-1661434301'
sh 'aws sts get-caller-identity'
sh 'ls'
sh "kubectl apply -f kubernetes.yml"
sh "kubectl set image deployment sample-spring-boot -n devopslab springboot-sample=dogistan/devopslab:latest"
}
}
}
}
}