forked from MithunTechnologiesDevOps/maven-web-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsScript
44 lines (43 loc) · 1.25 KB
/
jenkinsScript
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
pipeline {
agent any
tools{
maven "maven3.9.1"
}
parameters {
choice choices: ['master', 'development', 'qa'], name: 'Select branches'
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '4', daysToKeepStr: '', numToKeepStr: '4')
}
stages {
//checkoutStage
stage('Checkoutcode') {
steps {
git credentialsId: '0d6f4d5b-9765-41a5-948b-5f532da4042f', url: 'https://github.com/8978834438/maven-web-application.git'
}
}
//build
stage('Build') {
steps {
sh "mvn clean package"
}
}
stage('SonarQube') {
steps {
sh "mvn sonar:sonar"
}
}
stage('UploadArtifactoryIntoNexus') {
steps {
sh "mvn deploy"
}
}
stage('DeployAppIntoTomcatServer') {
steps {
sshagent(['3f3986f8-4324-45ef-8d61-0cf7abc6388c']) {
sh "scp -o StrictHostKeyChecking=no /var/lib/jenkins/workspace/Pipeline-DeclarativeWay/target/maven-web-application.war 'ec2-user@172.31.38.4':/opt/apache-tomcat-9.0.71/webapps"
}
}
}
}
}