forked from jleetutorial/maven-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
47 lines (42 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
pipeline {
agent any
parameters {
string(name: 'tomcat_dev', defaultValue: '100.27.23.86', description: 'Staging Server')
string(name: 'tomcat_prod', defaultValue: '54.145.88.106', description: 'Production Server')
}
triggers {
pollSCM('* * * * *')
}
stages{
stage('Build'){
steps {
// sh 'export PATH=/home/user/apache-maven-3.6.0/bin:$PATH'
sh '/home/user/apache-maven-3.6.0/bin/mvn clean package'
echo '------'
sh 'ls -la'
echo '------'
}
post {
success {
echo 'Now Archiving...'
sh 'ls -la'
archiveArtifacts artifacts: '**/target/*.jar'
}
}
}
stage ('Deployments'){
parallel{
stage ('deploy-to-staging'){
steps {
sh "scp **/target/*.jar user@${params.tomcat_dev}:/var/lib/tomcat/webapps"
}
}
stage ("deploy-to-prod"){
steps {
sh "scp **/target/*.jar user@${params.tomcat_prod}:/var/lib/tomcat/webapps"
}
}
}
}
}
}