Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ansible.yaml
deployment.yaml
Empty file added 123.txt
Empty file.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM tomcat
WORKDIR webapps
COPY target/WebApp.war .
RUN rm -rf ROOT && mv WebApp.war ROOT.war
ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"]
FROM tomcat
WORKDIR webapps
COPY target/WebApp.war .
RUN rm -rf ROOT && mv WebApp.war ROOT.war
ENTRYPOINT ["sh", "/usr/local/tomcat/bin/startup.sh"]
158 changes: 79 additions & 79 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
currentBuild.displayName = "Final_Demo # "+currentBuild.number

def getDockerTag(){
def tag = sh script: 'git rev-parse HEAD', returnStdout: true
return tag
}


pipeline{
agent any
environment{
Docker_tag = getDockerTag()
}

stages{


stage('Quality Gate Statuc Check'){

agent {
docker {
image 'maven'
args '-v $HOME/.m2:/root/.m2'
}
}
steps{
script{
withSonarQubeEnv('sonarserver') {
sh "mvn sonar:sonar"
}
timeout(time: 1, unit: 'HOURS') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
sh "mvn clean install"
}
}
}



stage('build')
{
steps{
script{
sh 'cp -r ../devops-training@2/target .'
sh 'docker build . -t deekshithsn/devops-training:$Docker_tag'
withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) {

sh 'docker login -u deekshithsn -p $docker_password'
sh 'docker push deekshithsn/devops-training:$Docker_tag'
}
}
}
}

stage('ansible playbook'){
steps{
script{
sh '''final_tag=$(echo $Docker_tag | tr -d ' ')
echo ${final_tag}test
sed -i "s/docker_tag/$final_tag/g" deployment.yaml
'''
ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml'
}
}
}



}





}
currentBuild.displayName = "Final_Demo # "+currentBuild.number
def getDockerTag(){
def tag = sh script: 'git rev-parse HEAD', returnStdout: true
return tag
}
pipeline{
agent any
environment{
Docker_tag = getDockerTag()
}
stages{
stage('Quality Gate Statuc Check'){
agent {
docker {
image 'maven'
args '-v $HOME/.m2:/root/.m2'
}
}
steps{
script{
withSonarQubeEnv('sonarserver') {
sh "mvn sonar:sonar"
}
timeout(time: 1, unit: 'HOURS') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
sh "mvn clean install"
}
}
}
stage('build')
{
steps{
script{
sh 'cp -r ../devops-training@2/target .'
sh 'docker build . -t deekshithsn/devops-training:$Docker_tag'
withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) {
sh 'docker login -u deekshithsn -p $docker_password'
sh 'docker push deekshithsn/devops-training:$Docker_tag'
}
}
}
}
stage('ansible playbook'){
steps{
script{
sh '''final_tag=$(echo $Docker_tag | tr -d ' ')
echo ${final_tag}test
sed -i "s/docker_tag/$final_tag/g" deployment.yaml
'''
ansiblePlaybook become: true, installation: 'ansible', inventory: 'hosts', playbook: 'ansible.yaml'
}
}
}
}
}
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@


# Build Instruction


```
mvn clean package
and build the instruction .
```

# Deploy instruction

Deploy ```target/WebApp.war``` on Tomcat properly for better experience.

# Build Instruction
```
mvn clean package
and build the instruction .
```
# Deploy instruction
Deploy ```target/WebApp.war``` on Tomcat properly for better experience.
22 changes: 11 additions & 11 deletions ansible.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
- hosts: test
tasks:
- name: copy deployment file to kubernetes master
copy:
src: deployment.yaml
dest: /root/
- name: delete the previous of kubernetes objects
command: kubectl delete -f /root/deployment.yaml
- name: Create a Deployment by reading the definition from a local file
command: kubectl apply -f /root/deployment.yaml

- hosts: test
tasks:
- name: copy deployment file to kubernetes master
copy:
src: deployment.yaml
dest: /root/
- name: delete the previous of kubernetes objects
command: kubectl delete -f /root/deployment.yaml
- name: Create a Deployment by reading the definition from a local file
command: kubectl apply -f /root/deployment.yaml
76 changes: 38 additions & 38 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: devops-training
spec:
selector:
matchLabels:
app: devops-training
template:
metadata:
labels:
app: devops-training
spec:
containers:
- name: devops-training
image: deekshithsn/devops-training:docker_tag
command: ["/bin/sh"]
args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
ports:
- name: http
containerPort: 8080
replicas: 2
---
apiVersion: v1
kind: Service
metadata:
name: devops-training-app-service
labels:
app: devops-training
spec:
type: NodePort
ports:
- port: 8080
nodePort: 31884
protocol: TCP
name: http
selector:
app: devops-training
apiVersion: apps/v1
kind: Deployment
metadata:
name: devops-training
spec:
selector:
matchLabels:
app: devops-training
template:
metadata:
labels:
app: devops-training
spec:
containers:
- name: devops-training
image: deekshithsn/devops-training:docker_tag
command: ["/bin/sh"]
args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
ports:
- name: http
containerPort: 8080
replicas: 2
---
apiVersion: v1
kind: Service
metadata:
name: devops-training-app-service
labels:
app: devops-training
spec:
type: NodePort
ports:
- port: 8080
nodePort: 31884
protocol: TCP
name: http
selector:
app: devops-training
4 changes: 2 additions & 2 deletions hosts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[test]
Host_ip
[test]
Host_ip
42 changes: 21 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lu.amazon.aws.demo</groupId>
<artifactId>WebApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>WebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>WebApp</finalName>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lu.amazon.aws.demo</groupId>
<artifactId>WebApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>WebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>WebApp</finalName>
</build>
</project>
14 changes: 7 additions & 7 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
8 changes: 4 additions & 4 deletions src/main/webapp/css/jumbotron.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
padding-bottom: 20px;
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
padding-bottom: 20px;
}
Loading