-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
516b644
commit d54bf85
Showing
11 changed files
with
759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM maven as build | ||
WORKDIR /app | ||
COPY . . | ||
RUN mvn install | ||
|
||
|
||
FROM openjdk:11.0 | ||
WORKDIR /app | ||
COPY --from=build /app/target/Uber.jar /app/ | ||
EXPOSE 9090 | ||
CMD [ "java" , "-jar" , "Uber.jar" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
pipeline { | ||
|
||
agent any | ||
|
||
stages{ | ||
|
||
stage('Git chceckout'){ | ||
|
||
steps{ | ||
git branch: 'main', url: 'https://github.com/PoudelAmrit123/ci-cd-pipeline.git' | ||
} | ||
} | ||
stage('Unit Test'){ | ||
steps{ | ||
sh 'mvn test' | ||
} | ||
} | ||
|
||
stage('Integrated testing'){ | ||
|
||
steps{ | ||
sh 'mvn verify -DskipUnitTests' | ||
} | ||
} | ||
|
||
stage('Maven Build'){ | ||
|
||
steps{ | ||
sh 'mvn clean install' | ||
} | ||
} | ||
|
||
stage('Static Code Analysis'){ | ||
|
||
steps{ | ||
script{ | ||
withSonarQubeEnv(credentialsId: 'sonar-api') { | ||
sh 'mvn clean package sonar:sonar' | ||
} | ||
} | ||
} | ||
} | ||
|
||
// stage('Quality Gate status'){ | ||
// steps{ | ||
|
||
// script{ | ||
// waitForQualityGate abortPipeline: false, credentialsId: 'sonar-api' | ||
// } | ||
// } | ||
|
||
|
||
// } | ||
|
||
stage('Upload jar File To nexus'){ | ||
|
||
steps{ | ||
script{ | ||
|
||
def readPomVersion = readMavenPom file: 'pom.xml' | ||
|
||
nexusArtifactUploader artifacts: | ||
[[artifactId: 'springboot', classifier: '', file: 'target/Uber.jar', type: 'jar']], | ||
credentialsId: 'nexus-auth', | ||
groupId: 'com.example', | ||
nexusUrl: '65.2.6.64:8081', | ||
nexusVersion: 'nexus3', | ||
protocol: 'http', | ||
repository: 'demoapp-release', | ||
version: "${readPomVersion.version}" | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
stage('Build Docker File'){ | ||
|
||
steps{ | ||
|
||
script{ | ||
|
||
sh 'docker image build -t $JOB_NAME:v1.$BUILD_ID .' | ||
sh 'docker image tag $JOB_NAME:v1.$BUILD_ID amritpoudel/$JOB_NAME:v1.$BUILD_ID' | ||
sh 'docker image tag $JOB_NAME:v1.$BUILD_ID amritpoudel/$JOB_NAME:latest' | ||
} | ||
} | ||
|
||
} | ||
|
||
stage('Push To Docker hub'){ | ||
|
||
steps{ | ||
|
||
script{ | ||
withCredentials([string(credentialsId: 'docker-cred', variable: 'docker_hub_cred')]) { | ||
sh 'docker login -u amritpoudel -p ${docker_hub_cred}' | ||
sh 'docker image push amritpoudel/$JOB_NAME:v1.$BUILD_ID ' | ||
sh 'docker image push amritpoudel/$JOB_NAME:latest ' | ||
// some block | ||
} | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mynodejs-app | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: mynodejs-app | ||
template: | ||
metadata: | ||
labels: | ||
app: mynodejs-app | ||
spec: | ||
containers: | ||
- name: mynodejs-app | ||
image: amritpoudel/demo-app:latest | ||
resources: | ||
limits: | ||
memory: "128Mi" | ||
cpu: "500m" | ||
ports: | ||
- containerPort: 8080 |
Oops, something went wrong.