forked from Sonal0409/DevOpsClassCodes
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathJenkinsfile1
More file actions
59 lines (53 loc) · 1.02 KB
/
Jenkinsfile1
File metadata and controls
59 lines (53 loc) · 1.02 KB
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
58
59
pipeline{
agent any
stages{
stage('checkout'){
steps{
git 'https://github.com/SobhaReddy/DevOpsClassCodes.git'
}
}
stage('compile'){
steps{
sh 'mvn compile'
}
}
stage('codeReview'){
steps{
sh 'mvn pmd:pmd'
}
}
stage('unitTest'){
steps{
sh 'mvn test'
}
}
/*stage('metricCheck'){
steps{
sh 'mvn cobertura:cobertura -Dcobertura.report.format=xml'
}
}*/
stage('package'){
steps{
sh 'mvn package'
}
}
stage('Deploy'){
agent any
steps{
sh label: '', script: '''rm -rf mydockerfile
mkdir mydockerfile
cd mydockerfile
cp /tmp/jenkins/workspace/package/target/addressbook.war .
touch dockerfile
cat <<EOT>> dockerfile
From tomcat
ADD addressbook.war /usr/local/tomcat/webapps
EXPOSE 8080
CMD ["catalina.sh", "run"]
EOT
sudo docker build -t myimage:$BUILD_NUMBER .
sudo docker run -itd -P myimage:$BUILD_NUMBER'''
}
}
}
}