diff --git a/Jenkinsfile b/Jenkinsfile index a2df42b1..eb728f42 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,30 +1,29 @@ pipeline{ - agent any - environment{ + agent any + environment { VERSION = "${env.BUILD_ID}" } stages{ stage("sonar quality check"){ agent { - docker { + docker{ image 'openjdk:11' } } steps{ script{ withSonarQubeEnv(credentialsId: 'sonar-token') { - sh 'chmod +x gradlew' - sh './gradlew sonarqube' + sh 'chmod +x gradlew' + sh './gradlew sonarqube' } - - timeout(time: 1, unit: 'HOURS') { - def qg = waitForQualityGate() - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" - } + timeout(7) { + def qg = waitForQualityGate() + if(qg.status != 'OK'){ + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } } + } - } } } stage("docker build & docker push"){ @@ -32,27 +31,27 @@ pipeline{ script{ withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) { sh ''' - docker build -t 34.125.214.226:8083/springapp:${VERSION} . - docker login -u admin -p $docker_password 34.125.214.226:8083 - docker push 34.125.214.226:8083/springapp:${VERSION} - docker rmi 34.125.214.226:8083/springapp:${VERSION} + docker build -t 34.125.93.147:8083/springapp:${VERSION} . + docker login -u admin -p $docker_password 34.125.93.147:8083 + docker push 34.125.93.147:8083/springapp:${VERSION} + docker rmi 34.125.93.147:8083/springapp:${VERSION} ''' } } } } - stage('indentifying misconfigs using datree in helm charts'){ + stage("indentifying misconfigs using datree in helm charts"){ steps{ script{ - - dir('kubernetes/') { - withEnv(['DATREE_TOKEN=GJdx2cP2TCDyUY3EhQKgTc']) { + dir('kubernetes/') { + withEnv(['DATREE_TOKEN=abd14242-b27a-4b93-b288-628a22413751']) { sh 'helm datree test myapp/' } } } } } + stage("pushing the helm charts to nexus"){ steps{ script{ @@ -61,7 +60,7 @@ pipeline{ sh ''' helmversion=$( helm show chart myapp | grep version | cut -d: -f 2 | tr -d ' ') tar -czvf myapp-${helmversion}.tgz myapp/ - curl -u admin:$docker_password http://34.125.214.226:8081/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v + curl -u admin:$docker_password http://34.125.93.147:8081/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v ''' } } @@ -73,19 +72,19 @@ pipeline{ 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') + 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: "tamagni2002@yahoo.fr"; + input(message: "Deploy ${params.project_name}?", ok: "Deploy") } } } } - stage('Deploying application on k8s cluster') { + stage('Deploying application xxx on k8s cluster') { steps { script{ - withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) { + withCredentials([kubeconfigContent(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG_CONTENT')]) { dir('kubernetes/') { - sh 'helm upgrade --install --set image.repository="34.125.214.226:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ ' + sh 'helm upgrade --install --set image.repository="34.125.93.147:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ ' } } } @@ -102,11 +101,11 @@ pipeline{ } } } - } - + } post { always { - mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
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"; - } - } + mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
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: "tamagni2021@gmail.com"; + } + } } + diff --git a/Jenkinsfile1 b/Jenkinsfile1 new file mode 100644 index 00000000..30480d89 --- /dev/null +++ b/Jenkinsfile1 @@ -0,0 +1,112 @@ +pipeline{ + agent any + environment{ + VERSION = "${env.BUILD_ID}" + } + stages{ + stage("sonar quality check"){ + agent { + docker { + image 'openjdk:11' + } + } + steps{ + script{ + withSonarQubeEnv(credentialsId: 'sonar-token') { + sh 'chmod +x gradlew' + sh './gradlew sonarqube' + } + + timeout(time: 1, unit: 'HOURS') { + def qg = waitForQualityGate() + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } + } + + } + } + } + stage("docker build & docker push"){ + steps{ + script{ + withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) { + sh ''' + docker build -t 34.125.214.226:8083/springapp:${VERSION} . + docker login -u admin -p $docker_password 34.125.214.226:8083 + docker push 34.125.214.226:8083/springapp:${VERSION} + docker rmi 34.125.214.226:8083/springapp:${VERSION} + ''' + } + } + } + } + stage('indentifying misconfigs using datree in helm charts'){ + steps{ + script{ + + dir('kubernetes/') { + withEnv(['DATREE_TOKEN=GJdx2cP2TCDyUY3EhQKgTc']) { + sh 'helm datree test myapp/' + } + } + } + } + } + stage("pushing the helm charts to nexus"){ + steps{ + script{ + withCredentials([string(credentialsId: 'docker_pass', variable: 'docker_password')]) { + dir('kubernetes/') { + sh ''' + helmversion=$( helm show chart myapp | grep version | cut -d: -f 2 | tr -d ' ') + tar -czvf myapp-${helmversion}.tgz myapp/ + curl -u admin:$docker_password http://34.125.214.226:8081/repository/helm-hosted/ --upload-file myapp-${helmversion}.tgz -v + ''' + } + } + } + } + } + + 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.93.147:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ ' + } + } + } + } + } + + stage('verifying app deployment'){ + steps{ + script{ + withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) { + sh 'kubectl run curl --image=curlimages/curl -i --rm --restart=Never -- curl myjavaapp-myapp:8080' + + } + } + } + } + } + + post { + always { + mail bcc: '', body: "
Project: ${env.JOB_NAME}
Build Number: ${env.BUILD_NUMBER}
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"; + } + } +} diff --git a/bin/main/application.properties b/bin/main/application.properties new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/bin/main/application.properties @@ -0,0 +1 @@ + diff --git a/bin/main/com/example/controller/HomeController.class b/bin/main/com/example/controller/HomeController.class new file mode 100644 index 00000000..f89b6354 Binary files /dev/null and b/bin/main/com/example/controller/HomeController.class differ diff --git a/bin/main/com/example/demo/SampleWebApplication.class b/bin/main/com/example/demo/SampleWebApplication.class new file mode 100644 index 00000000..ae4f25be Binary files /dev/null and b/bin/main/com/example/demo/SampleWebApplication.class differ diff --git a/bin/main/com/example/demo/ServletInitializer.class b/bin/main/com/example/demo/ServletInitializer.class new file mode 100644 index 00000000..4699b6ae Binary files /dev/null and b/bin/main/com/example/demo/ServletInitializer.class differ diff --git a/bin/main/templates/index.html b/bin/main/templates/index.html new file mode 100644 index 00000000..414eacf6 --- /dev/null +++ b/bin/main/templates/index.html @@ -0,0 +1,243 @@ + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + + + + + web app + + +

Sample Web application has been deployed with Github action

+ + + + + diff --git a/bin/test/com/example/demo/SampleWebApplicationTests.class b/bin/test/com/example/demo/SampleWebApplicationTests.class new file mode 100644 index 00000000..9ff8277d Binary files /dev/null and b/bin/test/com/example/demo/SampleWebApplicationTests.class differ diff --git a/build.gradle b/build.gradle index 2b60d6a0..99e43ad2 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ test { sonarqube { properties { - property 'sonar.host.url', 'http://34.125.201.58:9000' - property 'sonar.login', '******' + property 'sonar.host.url', 'http://34.125.1.203:9000' + property 'sonar.login', '73c3148c47cc350be96afd217f7a5dde56563563' } } diff --git a/ernest.code-workspace b/ernest.code-workspace new file mode 100644 index 00000000..24774970 --- /dev/null +++ b/ernest.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "../.." + }, + { + "path": "." + } + ] +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..03b2e37a --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +org.gradle.warning.mode=all \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/kubernetes/myapp/values.yaml b/kubernetes/myapp/values.yaml index a0e99a3a..faf98f6e 100644 --- a/kubernetes/myapp/values.yaml +++ b/kubernetes/myapp/values.yaml @@ -11,6 +11,5 @@ image: tag: IMAGE_TAG service: - type: NodePort - port: 8080 - + type: LoadBalancer + port: 8080 \ No newline at end of file diff --git a/tamagni2002 b/tamagni2002 new file mode 100644 index 00000000..2573d30c --- /dev/null +++ b/tamagni2002 @@ -0,0 +1,39 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABBrElct7u +8zoL9aH2c9WtTiAAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQCpu9Xxg12T +XFLHmp0wnoWODV9xhgQVZR1AfEZtxoPM1aRBR+aO0U8GyXcDKGRGy2SFhlkuDtxDkVnscu +Ihr0pipTSPuCZbnMbdzAjWE9ZlrGLXEQlm+ZOpi2ELYxxc0ZACLPMCeIRPIvfWM3HaVKQA +vj1X7YYYvz5s2Q2Xp9wV/uKlED47eWVZAzZilcPxRSjBoxWdbaTGsLXdB6EAxvoU4JVb06 +1aat5pok9LbOJrL6lATFfSviT11rrWruNPdPr2MVl56++VVtXFTmfTgXf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R1wNa7Tye9dDq56RXXmHGw= +-----END OPENSSH PRIVATE KEY----- diff --git a/tamagni2002.pub b/tamagni2002.pub new file mode 100644 index 00000000..7d283a9f --- /dev/null +++ b/tamagni2002.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCpu9Xxg12TXFLHmp0wnoWODV9xhgQVZR1AfEZtxoPM1aRBR+aO0U8GyXcDKGRGy2SFhlkuDtxDkVnscuIhr0pipTSPuCZbnMbdzAjWE9ZlrGLXEQlm+ZOpi2ELYxxc0ZACLPMCeIRPIvfWM3HaVKQAvj1X7YYYvz5s2Q2Xp9wV/uKlED47eWVZAzZilcPxRSjBoxWdbaTGsLXdB6EAxvoU4JVb061aat5pok9LbOJrL6lATFfSviT11rrWruNPdPr2MVl56++VVtXFTmfTgXfBvK0N/1M1x0kDGheg8ugxFLpSIvldCWwi2A9e+13h2hbjZuztnYg71XsJEPIQZIzr+MNqGyxXZ51PSs08t1/AbCGavdppVjMeTLqO22flT+X5bIgGY+e6IOG7RrOLv7W2by2RycRoTRjRvS3CgLd3yGpfe3wVxmhg9h+kEESn6YItmBnp6YSyF7qSlZcGTs3rwKceJyaYbK6Y361FOOOP6CWz96uRAZfd/sTEeL74lmE= root@ernest