Skip to content

Commit 854e8fd

Browse files
committed
2 parents d59c88f + 55ed7d7 commit 854e8fd

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
FROM tomcat:8.0
2-
RUN cp -a **/*.war /usr/local/tomcat/webapps/
2+
3+
# Maintainer
4+
MAINTAINER "Bipin Singh"
5+
6+
# COPY path-to-your-application-war path-to-webapps-in-docker-tomcat
7+
ADD ./target/java-tomcat-maven-example.war /usr/local/tomcat/webapps
8+
39
EXPOSE 8080
4-
CMD ["catalina.sh", "run"]
10+
11+
CMD ["catalina.sh", "run"]
Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
pipeline {
22
agent any
33
stages {
4+
stage('Initialize Git POLL SCM Feature') {
5+
steps {
6+
//enable remote triggers
7+
script {
8+
properties([[$class: 'GithubProjectProperty', displayName: '', projectUrlStr: 'https://github.com/bipin115/PG_DevOps_SimpliLearn_Projects.git/'], pipelineTriggers([pollSCM('* * * * *')])])
9+
}
10+
}
11+
}
12+
stage('Git project checkout') {
13+
steps {
14+
git branch: 'main', url: 'https://github.com/bipin115/PG_DevOps_SimpliLearn_Projects.git'
15+
}
16+
}
417
stage('Build Application') {
518
steps {
6-
sh 'mvn -f pom.xml clean package'
19+
sh 'mvn -f java-tomcat-sample-docker/pom.xml clean package'
720
}
821
post {
922
success {
@@ -13,13 +26,35 @@ pipeline {
1326
}
1427
}
1528

16-
stage('Create Tomcat Docker Image'){
29+
stage('Docker Build and Tag') {
30+
steps {
31+
32+
sh 'docker build -t samplewebapp:latest .'
33+
sh 'docker tag samplewebapp bipin115/samplewebapp:latest'
34+
}
35+
}
36+
37+
stage('Publish image to Docker Hub') {
38+
1739
steps {
18-
sh "pwd"
19-
sh "ls -a"
20-
sh "docker build -t tomcatsamplewebapp:${env.BUILD_ID} ."
40+
withDockerRegistry([ credentialsId: "dockerHub", url: "" ]) {
41+
sh 'docker push bipin115/samplewebapp:lates'
42+
}
43+
}
44+
}
45+
46+
stage('Run Docker container on Jenkins Agent') {
47+
48+
steps {
49+
sh "docker run -d -p 9090:8080 bipin115/samplewebapp"
50+
}
51+
}
52+
53+
stage('Run Docker container on remote hosts') {
54+
55+
steps {
56+
sh "docker -H ssh://jenkins@localhost run -d -p 8003:8080 bipin115/samplewebapp"
2157
}
2258
}
23-
2459
}
25-
}
60+
}

0 commit comments

Comments
 (0)