forked from sudheer76R/java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsrsync
More file actions
35 lines (35 loc) · 856 Bytes
/
jenkinsrsync
File metadata and controls
35 lines (35 loc) · 856 Bytes
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
pipeline {
agent none
stages {
stage('Checkout') {
agent {label 'master'}
steps {
git branch: 'main', url: 'https://github.com/hudge1/java-example.git'
}
}
stage('Static-test') {
agent {label 'master'}
steps {
echo 'Running static tests on code'
}
}
stage('Build') {
environment {
private_key=credentials('ssh_key')
}
agent {label 'master'}
steps {
sh 'mvn clean package'
sh 'rsync -avzh -e "ssh -i ${private_key} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" $WORKSPACE/target/*.war [email protected]:/home/ubuntu'
}
}
stage('Deploy') {
agent {label 'tomcatsp'}
steps {
echo 'Deploying into Dev environment'
sh 'sudo cp -r /home/ubuntu/*.war /home/ec2-user/tomcat/webapps/'
sh 'sudo rm -rf /home/ubuntu/*.war'
}
}
}
}