Skip to content

Haresing/deploy to dev only if master #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
94d7c6b
Create Jenkinsfile
harendrasp Sep 29, 2023
62aee2f
save artifact
harendrasp Sep 29, 2023
da98c2d
Update index.jsp
harendrasp Sep 29, 2023
56afb85
Update index.jsp
harendrasp Sep 29, 2023
980b185
Merge pull request #2 from harendrasp/harendrasp/newBranch2
harendrasp Sep 29, 2023
87e319c
Merge branch 'master' into harendrasp/newBranch1
harendrasp Sep 29, 2023
f6c6c47
Merge pull request #1 from harendrasp/harendrasp/newBranch1
harendrasp Sep 29, 2023
64b5bf8
Added Jenkinsfile
harendrasp Sep 29, 2023
c577341
Merge pull request #4 from harendrasp/usedockeragent(jenkinschange)
harendrasp Sep 29, 2023
c8683c2
Update index.jsp
harendrasp Oct 4, 2023
4f0b86a
Added Jenkinsfile
harendrasp Oct 4, 2023
fa70a5a
Added Jenkinsfile
harendrasp Oct 4, 2023
ee60c9d
Added Jenkinsfile
harendrasp Oct 4, 2023
2b72950
Create Dockerfile
harendrasp Oct 4, 2023
245b5bc
Merge pull request #5 from harendrasp/haresing/FixingBug
harendrasp Oct 4, 2023
2218c95
Update Jenkinsfile
harendrasp Oct 4, 2023
fbc04a1
Parallel package and jobs
harendrasp Oct 4, 2023
fd22766
Added Jenkinsfile
harendrasp Oct 4, 2023
e4f8b59
Added Jenkinsfile
harendrasp Oct 4, 2023
a8ab65a
Merge pull request #6 from harendrasp/haresingParallelJobs
harendrasp Oct 4, 2023
331b1a5
Merge branch 'master' into haresing/onlyIfMaster
harendrasp Oct 4, 2023
a04fe6b
Merge pull request #7 from harendrasp/haresing/onlyIfMaster
harendrasp Oct 4, 2023
44b17be
Added Jenkinsfile
harendrasp Oct 4, 2023
5723354
Create docker-compose.yaml
harendrasp Oct 4, 2023
c8b8911
Merge pull request #9 from harendrasp/haresing/deployToDev
harendrasp Oct 4, 2023
11153b2
deployToDevOnlyIfMaster
harendrasp Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM maven:3.6.3-jdk-11-slim as build
WORKDIR /opt/demo
COPY . /opt/demo
RUN mvn package -DskipTests

FROM tomcat:jre8-openjdk-slim-buster as run
WORKDIR /usr/local/tomcat
COPY --from=build /opt/demo/target/sysfoo.war webapps/ROOT.war
87 changes: 87 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
pipeline {
agent none
stages {
stage('build') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
echo 'compile maven app'
sh 'mvn compile'
}
}

stage('test') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
echo 'Test maven app'
sh 'mvn clean test'
}
}

stage('package') {
when {
branch 'master'
}
parallel {
stage('package') {
agent {
docker {
image 'maven:3.6.3-jdk-11-slim'
}

}
steps {
echo 'package maven app'
sh 'mvn package -DskipTests'
archiveArtifacts 'target/*war'
}
}

stage('Docker B&P2') {
agent any
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') {
def dockerImage = docker.build("letmeplay/sysfoo:v${env.BUILD_ID}", "./")
dockerImage.push()
dockerImage.push("latest")
dockerImage.push("dev")
}
}

}
}

}
}

stage('deployToDev') {
when {
branch 'master'
}
agent any
steps {
sh 'docker-compose up -d'
}
}

}
tools {
maven 'Maven 3.6.3'
}
post {
always {
echo 'This pipeline is completed..'
}

}
}
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "3.8"

services:
sysfoo:
image: letmeplay/sysfoo:dev
ports:
- 8888:8080
2 changes: 1 addition & 1 deletion src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<html>
<head>
<title>Sysfoo Demo App by School of Devops</title>
<meta charset="utf-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><![endif]-->
Expand Down