Skip to content
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

dev #7

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
fd4ab0b
Create README.md
muqeeth23 Dec 14, 2021
37a82fc
starting point
muqeeth23 Dec 15, 2021
ef3718b
added qualitygate
muqeeth23 Dec 15, 2021
9d8ad6c
removed comments
muqeeth23 Dec 15, 2021
105e93c
bug fixed
muqeeth23 Dec 15, 2021
f0da37b
bug fixed
muqeeth23 Dec 15, 2021
58682af
bug fixed
muqeeth23 Dec 15, 2021
0992fd1
checking
muqeeth23 Dec 15, 2021
97d5e21
check
muqeeth23 Dec 16, 2021
22cc911
check
muqeeth23 Dec 16, 2021
3a76960
removed agent docker
muqeeth23 Dec 16, 2021
020e239
introduced a bug
muqeeth23 Dec 16, 2021
882904a
check
muqeeth23 Dec 16, 2021
9cd57c3
check
muqeeth23 Dec 16, 2021
ba18112
check
muqeeth23 Dec 16, 2021
e77cd74
test mvn command
muqeeth23 Dec 16, 2021
87fc7b0
test
muqeeth23 Dec 16, 2021
4541a5b
test
muqeeth23 Dec 16, 2021
c6c7a35
check
muqeeth23 Dec 16, 2021
6293c55
bug
muqeeth23 Dec 16, 2021
0954447
bug
muqeeth23 Dec 16, 2021
0233256
bug1
muqeeth23 Dec 16, 2021
40d7f85
bug2
muqeeth23 Dec 16, 2021
cbd4126
bug3
muqeeth23 Dec 16, 2021
3efd27b
bug4
muqeeth23 Dec 16, 2021
7cbdf89
bug5
muqeeth23 Dec 16, 2021
ef3df77
bug6
muqeeth23 Dec 16, 2021
47b0d3f
bug7
muqeeth23 Dec 16, 2021
31ce019
bug8
muqeeth23 Dec 16, 2021
720c055
bug9
muqeeth23 Dec 16, 2021
eadc189
testing
muqeeth23 Dec 16, 2021
5d36763
new test
muqeeth23 Dec 16, 2021
ed4c3d6
retest
muqeeth23 Dec 16, 2021
1bd1f42
test2
muqeeth23 Dec 16, 2021
3be7665
test3
muqeeth23 Dec 16, 2021
e79be79
random test
muqeeth23 Dec 16, 2021
5517b27
testing
muqeeth23 Dec 16, 2021
b255ef1
test again
muqeeth23 Dec 16, 2021
4749335
add function
muqeeth23 Dec 16, 2021
bf161e2
check
muqeeth23 Dec 16, 2021
d0f6f39
added bug code
muqeeth23 Dec 16, 2021
696b946
new sonar server
muqeeth23 Dec 16, 2021
b90aa21
check
muqeeth23 Dec 16, 2021
f3ca2a1
removed bug
muqeeth23 Dec 16, 2021
a0d1e3e
test
muqeeth23 Dec 16, 2021
107d265
check
muqeeth23 Dec 16, 2021
adec097
test
muqeeth23 Dec 16, 2021
2c3d102
nexus
muqeeth23 Dec 16, 2021
6e381fa
bug fixes
muqeeth23 Dec 16, 2021
63a29bc
building war file
muqeeth23 Dec 16, 2021
63b3f5d
fixed compilation error
muqeeth23 Dec 16, 2021
bc25a8e
fixed compilation error
muqeeth23 Dec 16, 2021
ddf686c
try
muqeeth23 Dec 16, 2021
d469298
mesS
muqeeth23 Dec 16, 2021
96810e5
message
muqeeth23 Dec 16, 2021
cca4310
bug fix
muqeeth23 Dec 16, 2021
1102c69
fix
muqeeth23 Dec 16, 2021
0566f3f
fix
muqeeth23 Dec 16, 2021
6e62cd6
bug fix
muqeeth23 Dec 16, 2021
34435c9
dependancy added
muqeeth23 Dec 16, 2021
ec55a96
message
muqeeth23 Dec 16, 2021
367240c
message
muqeeth23 Dec 16, 2021
929ccd0
message
muqeeth23 Dec 16, 2021
4d698f8
test
muqeeth23 Dec 16, 2021
6d36703
test1
muqeeth23 Dec 16, 2021
facd12b
test2
muqeeth23 Dec 16, 2021
faa36fc
test3
muqeeth23 Dec 16, 2021
229f709
test4
muqeeth23 Dec 16, 2021
e2b570b
added docker stage
muqeeth23 Dec 17, 2021
830795e
added dockerfile
muqeeth23 Dec 17, 2021
1e7177e
modified
muqeeth23 Dec 17, 2021
b47ad11
email notification
muqeeth23 Dec 17, 2021
c6b05ac
fix
muqeeth23 Dec 17, 2021
ac3d458
post step
muqeeth23 Dec 17, 2021
155e60a
added manifest
muqeeth23 Dec 27, 2021
1ffbd3d
added dockerignore file
muqeeth23 Dec 27, 2021
b6fa377
added service file
muqeeth23 Dec 27, 2021
f328695
added secret manifest
muqeeth23 Dec 27, 2021
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
k8smanifest/*
.gitignore
Jenkinsfile
README.md
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#build war file
FROM maven:3.8-openjdk-8-slim as buildstage
RUN mkdir /app
WORKDIR /app
COPY src /app/src
COPY pom.xml /app
RUN mvn -f /app/pom.xml clean package



#Deploying into tomcat
FROM tomcat:9.0
RUN mv webapps webapps2
RUN cp -r webapps.dist/ webapps

COPY --from=buildstage /app/target/WebAppCal-1.3.2.war /usr/local/tomcat/webapps/webappcal.war
80 changes: 72 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,87 @@
pipeline {
agent any
environment{
VERSION = "${env.BUILD_ID}"
}

stages {
stage('CODE-VALIDATION') {
stage('sonarQualityCheck') {
steps {
script {
withSonarQubeEnv('sonar-server') {
echo 'validatining code..'
sh 'mvn clean sonar:sonar'

}

timeout(time: 1, unit: 'HOURS'){
def qg = waitForQualityGate()
if (qg.status != 'OK'){
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}

stage('Build war file') {
steps {
sh 'mvn clean package'
}
}

stage('Nexus Release') {
steps {
nexusArtifactUploader artifacts: [[artifactId: 'WebAppCal', classifier: '', file: 'target/WebAppCal-1.3.2.war', type: 'war']], credentialsId: 'nexus', groupId: 'com.web.cal', nexusUrl: '172.31.44.35:8081/', nexusVersion: 'nexus3', protocol: 'http', repository: 'maven-releases', version: '1.3.2'

}
}

stage('docker build and docker push') {
steps {
echo 'validate code..'
sh 'mvn validate compile'
script{
withCredentials([string(credentialsId: 'registry_pw', variable: 'registry_password')]) {
sh '''
docker build -t 172.31.44.35:8082/webappcal:${VERSION} .
docker tag 172.31.44.35:8082/webappcal:${VERSION} 172.31.44.35:8082/webappcal:latest
docker login -u admin -p $registry_password 172.31.44.35:8082
docker push 172.31.44.35:8082/webappcal:${VERSION}
docker rmi 172.31.44.35:8082/webappcal:${VERSION}
'''
}

}
}
}
stage('Unit Test') {
stage('Manual approval') {
steps {
echo 'Testing..'
sh 'mvn test'
timeout(10) {
mail bcc: '', body: "Please click on the below link to review and approve deployment http://13.233.214.250:8080/job/pipeline_test/${env.BUILD_NUMBER}/console ", cc: '', from: '', replyTo: '', subject: 'Need approval to deploy', to: '[email protected]'
input id: 'Deploygate', message: "Deploy ${env.JOB_NAME}?", ok: 'deploy'
}
}
}
stage('Deploy') {

stage('Deploy with approval') {
steps {
echo 'Deploying....'
script{
withCredentials([kubeconfigFile(credentialsId: '7f2f53d9-632b-46e9-a7fc-ab7349cdf007', variable: 'KUBECONFIG')]) {
dir('k8smanifest') {
kubectl apply -f registrysecret.yml
kubectl apply -f deployment.yml
kubectl apply -f service.yml
}

}
}

}
}

}
post {
always {
mail bcc: '', body: "<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "${currentBuild.result} CI: Project name -> ${env.JOB_NAME}", to: "[email protected]";
}
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Java Project
Build tool is Maven

when we build the code using command $mvn package it will generate war file. that war can be placed in tomcat server to see application web page

code is integrated with sonarqube plugin which help us in static code analysis

21 changes: 21 additions & 0 deletions k8smanifest/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: webappcal
name: webappcal
spec:
replicas: 2
selector:
matchLabels:
app: webappcal
template:
metadata:
labels:
app: webappcal
spec:
imagePullSecrets:
- name: registry-secret
containers:
- image: 172.31.44.35:8082/webappcal
name: webappcal
7 changes: 7 additions & 0 deletions k8smanifest/registrysecret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
.dockerconfigjson: eyJhdXRocyI6eyJodHRwOi8vMTcyLjMxLjQ0LjM1OjgwODIiOnsidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiYWRtaW4xMjMiLCJlbWFpbCI6ImFkbWluQHRlc3QuY29tIiwiYXV0aCI6IllXUnRhVzQ2WVdSdGFXNHhNak09In19fQ==
kind: Secret
metadata:
name: registry-secret
type: kubernetes.io/dockerconfigjson
14 changes: 14 additions & 0 deletions k8smanifest/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: webappcal
name: webappcal
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: webappcal
type: LoadBalancer
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>


</dependencies>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://52.53.153.183:8081/nexus/content/repositories/releases</url>
<url></url>
</repository>
</distributionManagement>
</project>
13 changes: 9 additions & 4 deletions src/main/java/mypackage/Calculator.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
package mypackage;

import static java.lang.System.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Calculator extends HttpServlet
{

public long addFucn(long first, long second){

return first+second;
}

public long subFucn(long first, long second){

return second-first;
return second/first;
}

public long mulFucn(long first, long second){

return first*second;
}


@Override

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{


try
{
response.setContentType("text/html");
Expand All @@ -50,7 +55,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
}
catch(Exception e)
{

}
out.println("something went wrong");
}
}
}