forked from jyothsnajyo244/maven-web-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
54 lines (47 loc) · 1.31 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
node{
stage('Clone repo'){
git credentialsId: 'GIT-Credentials', url: 'https://github.com/ashokitschool/maven-web-app.git'
}
stage('Maven Build'){
def mavenHome = tool name: "Maven-3.8.6", type: "maven"
def mavenCMD = "${mavenHome}/bin/mvn"
sh "${mavenCMD} clean package"
}
stage('SonarQube analysis') {
withSonarQubeEnv('Sonar-Server-7.8') {
sh "mvn sonar:sonar"
}
stage('upload war to nexus'){
steps{
nexusArtifactUploader artifacts: [
[
artifactId: '01-maven-web-app',
classifier: '',
file: 'target/01-maven-web-app.war',
type: war
]
],
credentialsId: 'nexus3',
groupId: 'in.ashokit',
nexusUrl: '',
protocol: 'http',
repository: 'ashokit-release'
version: '1.0.0'
}
}
stage('Build Image'){
sh 'docker build -t ashokit/mavenwebapp .'
}
stage('Push Image'){
withCredentials([string(credentialsId: 'DOCKER-CREDENTIALS', variable: 'DOCKER_CREDENTIALS')]) {
sh 'docker login -u ashokit -p ${DOCKER_CREDENTIALS}'
}
sh 'docker push ashokit/mavenwebapp'
}
stage('Deploy App'){
kubernetesDeploy(
configs: 'maven-web-app-deploy.yml',
kubeconfigId: 'Kube-Config'
)
}
}