-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
51 lines (39 loc) · 1.44 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
node {
def sonarUrl = 'sonar.host.url=http://172.31.30.136:9000'
def mvn = tool (name: 'maven3', type: 'maven') + '/bin/mvn'
stage('SCM Checkout'){
// Clone repo
git branch: 'master',
credentialsId: 'github',
url: 'https://github.com/javahometech/myweb'
}
stage('Sonar Publish'){
withCredentials([string(credentialsId: 'sonarqube', variable: 'sonarToken')]) {
def sonarToken = "sonar.login=${sonarToken}"
sh "${mvn} sonar:sonar -D${sonarUrl} -D${sonarToken}"
}
}
stage('Mvn Package'){
// Build using maven
sh "${mvn} clean package deploy"
}
stage('deploy-dev'){
def tomcatDevIp = '172.31.28.172'
def tomcatHome = '/opt/tomcat8/'
def webApps = tomcatHome+'webapps/'
def tomcatStart = "${tomcatHome}bin/startup.sh"
def tomcatStop = "${tomcatHome}bin/shutdown.sh"
sshagent (credentials: ['tomcat-dev']) {
sh "scp -o StrictHostKeyChecking=no target/myweb*.war ec2-user@${tomcatDevIp}:${webApps}myweb.war"
sh "ssh ec2-user@${tomcatDevIp} ${tomcatStop}"
sh "ssh ec2-user@${tomcatDevIp} ${tomcatStart}"
}
}
stage('Email Notification'){
mail bcc: '', body: """Hi Team, You build successfully deployed
Job URL : ${env.JOB_URL}
Job Name: ${env.JOB_NAME}
Thanks,
DevOps Team""", cc: '', from: '', replyTo: '', subject: "${env.JOB_NAME} Success", to: '[email protected]'
}
}