forked from javahometech/myweb
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Jenkins-sonar-nexus-tomcat
57 lines (51 loc) · 1.73 KB
/
Jenkins-sonar-nexus-tomcat
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
pipeline{
agent any
tools {
maven 'Maven-3.6.1'
}
environment{
PATH = "/opt/maven3/bin:$PATH"
}
stages{
stage("Git Checkout"){
steps{
git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git'
}
}
stage("Maven Build"){
steps{
sh "mvn clean sonar:sonar package"
}
}
stage('Upload War To Nexus'){
steps{
nexusArtifactUploader artifacts: [
[
artifactId: 'myweb',
classifier: '',
file: "target/myweb-8.2.0.war",
type: 'war'
]
],
credentialsId: 'nexus3',
groupId: 'in.javahome',
nexusUrl: '172.31.40.8:8081',
nexusVersion: 'nexus3',
protocol: 'http',
repository: 'sample-releases',
version: '8.2.0'
}
}
stage("deploy-dev"){
steps{
sshagent(['tomcat-new']) {
sh """
scp -o StrictHostKeyChecking=no target/myweb-8.2.0.war [email protected]:/home/ec2-user/apache-tomcat-9.0.64/webapps/
ssh [email protected] /home/ec2-user/apache-tomcat-9.0.64/bin/shutdown.sh
ssh [email protected] /home/ec2-user/apache-tomcat-9.0.64/bin/startup.sh
"""
}
}
}
}
}