diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9235cdb8..1b31ebe2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,8 +16,12 @@ jobs:
with:
java-version: '11'
distribution: 'adopt'
- cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
+
+ - name: Install Datree
+ run: curl https://get.datree.io | /bin/bash
+ - name: Run Datree's policy check
+ run: datree test kube.yaml
diff --git a/JenkinsfileFilter b/JenkinsfileFilter
new file mode 100644
index 00000000..1c68c70e
--- /dev/null
+++ b/JenkinsfileFilter
@@ -0,0 +1,23 @@
+pipeline {
+ agent {
+ docker {
+ image 'openjdk:11'
+ }
+ }
+
+ stages {
+ stage('Building') {
+ steps {
+ sh 'chmod +x gradlew'
+ sh "./gradlew build | tee output.log"
+ }
+ }
+ stage('Monitoring the logs') {
+ steps {
+ script {
+ sh '! grep "Task" output.log'
+ }
+ }
+ }
+ }
+}
diff --git a/JenkinsfileSharedLibrary b/JenkinsfileSharedLibrary
new file mode 100644
index 00000000..0a04c9fb
--- /dev/null
+++ b/JenkinsfileSharedLibrary
@@ -0,0 +1,26 @@
+#!/usr/bin/env groovy
+
+@Library('shared-library@master') _ //master or whatever branch
+
+
+pipeline {
+ agent {
+ docker {
+ image 'openjdk:11'
+ }
+ }
+
+ stages {
+ stage('Building') {
+ steps {
+ sh 'chmod +x gradlew'
+ sh "./gradlew build "
+ }
+ }
+ stage ('Check logs') {
+ steps {
+ filterLogs ('Task', 15)
+ }
+ }
+ }
+}
diff --git a/Jenkinsfile_demo b/Jenkinsfile_demo
new file mode 100644
index 00000000..8fb707fa
--- /dev/null
+++ b/Jenkinsfile_demo
@@ -0,0 +1,96 @@
+pipeline{
+ agent any
+ environment{
+ VERSION = "${env.BUILD_ID}"
+ }
+ stages{
+ stage("sonar qube analysis"){
+ agent{
+ docker {
+ image 'openjdk:11'
+ }
+ }
+ steps{
+ script{
+ withSonarQubeEnv(credentialsId: 'sonar-token-test') {
+ sh '''
+ chmod +x gradlew
+ ./gradlew sonarqube
+ '''
+ }
+
+ timeout(5) {
+ def qg = waitForQualityGate()
+ if (qg.status != 'OK') {
+ error "Pipeline aborted due to quality gate failure: ${qg.status}"
+ }
+ }
+ }
+ }
+ }
+
+ stage("building docker image and pushing it to nexus"){
+ steps{
+ script{
+
+ withCredentials([string(credentialsId: 'nexus_pass', variable: 'docker_pass')]) {
+ sh '''
+
+ docker build -t 34.125.203.155:8083/springapp:${VERSION} .
+ docker login -u admin -p $docker_pass 34.125.203.155:8083
+ docker push 34.125.203.155:8083/springapp:${VERSION}
+ docker rmi 34.125.203.155:8083/springapp:${VERSION}
+ docker image prune -f
+ '''
+ }
+ }
+ }
+ }
+
+
+ stage('manual approval'){
+ steps{
+ script{
+ timeout(10) {
+ mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
Go to build url and approve the deployment request
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: "deekshith.snsep@gmail.com";
+ // input(id: "Deploy Gate", message: "Deploy ${params.project_name}?", ok: 'Deploy')
+ }
+ }
+ }
+ }
+
+
+
+ stage('Deploying application on k8s cluster') {
+ steps {
+ script{
+ withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
+ dir('kubernetes/') {
+
+ sh 'helm upgrade --install --set image.repository="34.125.203.155:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ '
+ }
+ }
+ }
+ }
+ }
+
+
+ stage('verifying app deployment'){
+ steps{
+ script{
+ withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
+ sh '''
+
+ chmod +x healthcheck.sh
+ ./healthcheck.sh
+ '''
+
+ }
+ }
+ }
+ }
+
+
+ }
+
+}
diff --git a/README.md b/README.md
index 93676f58..3c95fe9d 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,6 @@ build tool is ** gradle **
when we build the code using command ```./gradlew build ``` 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
+code is integrated with sonarqube plugin which help us in static code analysis
-``` ./gradlew sonarqube ```
\ No newline at end of file
+``` ./gradlew sonarqube ```
diff --git a/build.gradle b/build.gradle
index 1e8ba502..2b60d6a0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,7 +28,7 @@ test {
sonarqube {
properties {
- property 'sonar.host.url', 'http://34.125.75.197:9000'
+ property 'sonar.host.url', 'http://34.125.201.58:9000'
property 'sonar.login', '******'
}
}
diff --git a/healthcheck.sh b/healthcheck.sh
new file mode 100644
index 00000000..c0244ee6
--- /dev/null
+++ b/healthcheck.sh
@@ -0,0 +1,10 @@
+echo "executing health check it might take a while"
+sleep 120
+kubectl run curl --image=curlimages/curl -i --rm --restart=Never -- curl myjavaapp-myapp:8080
+
+if [ $? -eq 0 ]
+then
+ echo "The Deployment is success...Application Health is Good"
+else
+ helm rollback myjavaapp
+fi
diff --git a/kube.yaml b/kube.yaml
index cce8f1cc..e8c08057 100644
--- a/kube.yaml
+++ b/kube.yaml
@@ -1,4 +1,4 @@
-
+# This is kube.yml notes
---
apiVersion: v1
kind: Service
@@ -47,7 +47,7 @@ spec:
- name: registry-secret
containers:
- name: myapp
- image: nginx:1.0
+ image: nginx:3.0
command: ["/bin/sh"]
args: ["-c","sh /usr/local/tomcat/bin/startup.sh;while true; do echo hello; sleep 10;done"]
imagePullPolicy: IfNotPresent
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 017ca718..414eacf6 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -4,7 +4,240 @@