forked from avinashmamidi/maven-project-2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
59 lines (56 loc) · 1.22 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
pipeline {
agent any
environment {
WORKSPACE = "${env.WORKSPACE}"
}
tools {
maven 'localMaven'
jdk 'localJdk'
}
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
post {
success {
echo ' now Archiving '
archiveArtifacts artifacts: '**/*.war'
}
}
}
stage('SonarQube Scan') {
steps {
sh """mvn sonar:sonar \
-Dsonar.host.url=http://3.238.69.44:9000 \
-Dsonar.login=253b4cee43f104bc93ae6ccb2b028f5b804fe2ad"""
}
}
stage('Upload to Artifactory') {
steps {
sh "mvn clean deploy -DskipTests"
}
}
stage('Deploy to DEV') {
environment {
HOSTS = "dev"
}
steps {
sh "ansible-playbook ${WORKSPACE}/deploy.yaml --extra-vars \"hosts=$HOSTS workspace_path=$WORKSPACE\""
}
}
stage('Approval') {
steps {
input('Do you want to proceed?')
}
}
stage('Deploy to PROD') {
environment {
HOSTS = "prod"
}
steps {
sh "ansible-playbook ${WORKSPACE}/deploy.yaml --extra-vars \"hosts=$HOSTS workspace_path=$WORKSPACE\""
}
}
}
}