-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
83 lines (71 loc) · 2.18 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
pipeline {
agent {label 'slave-1'}
environment {
imagename = "drwizzy/abctechnologies"
dockerImage = ''
appName = "abctechnologies"
}
tools {
// Install the Maven version configured as "M3" and add it to the path.
maven "Maven"
}
stages {
stage('Code Checkout'){
steps{
git branch: 'main', changelog: false, poll: false, url: 'https://github.com/kemsoft/ABC-Tech.git'
}
}
stage('Compile'){
steps{
sh 'mvn compile'
}
}
stage('Test'){
steps{
sh 'mvn test'
}
}
stage('Package WAR') {
steps {
sh "mvn -Dmaven.test.failure.ignore=true clean package"
}
post {
// If Maven was able to run the tests, even if some of the test
// failed, record the test results and archive the jar file.
success {
jacoco()
junit '**/target/surefire-reports/TEST-*.xml'
archiveArtifacts 'target/*.war'
}
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t abctechnologies .'
echo 'Image Build Completed!!'
sh "docker tag abctechnologies:latest drwizzy/abctechnologies:$BUILD_TAG"
sh "docker images"
}
}
stage('Publish Docker Image') {
steps {
echo 'Logging to Docker Hub...'
script {
withDockerRegistry(credentialsId: 'dockerhub', url: '') {
docker.image("drwizzy/abctechnologies:$BUILD_TAG").push()
}
}
}
}
stage('Remove Docker Images') {
steps {
sh 'docker image rmi $(docker images -a -q) --force'
}
}
stage('Create EKS Deployment and Service') {
steps {
sh 'ansible-playbook deployment-playbook.yml'
}
}
}
}