diff --git a/123Dockerfile b/123Dockerfile new file mode 100644 index 0000000000..69084ef35d --- /dev/null +++ b/123Dockerfile @@ -0,0 +1,6 @@ +FROM tomcat:8.0.20-jre8 +# Dummy text to test +COPY target/myweb*.war /usr/local/tomcat/webapps/myweb.war + +# Git webhook trigger demo +# TO test github push trigger diff --git a/Dockerfile b/Dockerfile index 69084ef35d..720df6b3d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,3 @@ FROM tomcat:8.0.20-jre8 # Dummy text to test COPY target/myweb*.war /usr/local/tomcat/webapps/myweb.war -# Git webhook trigger demo -# TO test github push trigger diff --git a/Jenkins-ansible b/Jenkins-ansible new file mode 100644 index 0000000000..46984c7360 --- /dev/null +++ b/Jenkins-ansible @@ -0,0 +1,48 @@ +pipeline{ + agent any + tools { + maven 'Maven-3.6.1' + } + + environment{ + PATH = "/opt/maven3/bin:$PATH" + } + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean sonar:sonar package" + + } + } + stage('Upload War To Nexus'){ + steps{ + nexusArtifactUploader artifacts: [ + [ + artifactId: 'myweb', + classifier: '', + file: "target/myweb-8.2.0.war", + type: 'war' + ] + ], + credentialsId: 'nexus3', + groupId: 'in.javahome', + nexusUrl: '172.31.42.135:8081', + nexusVersion: 'nexus3', + protocol: 'http', + repository: 'sample-releases', + version: '8.2.0' + } + } + stage("Execute Ansible"){ + steps{ + ansiblePlaybook credentialsId: 'private-key', disableHostKeyChecking: true, installation: 'ansible2', inventory: 'dev.in', playbook: 'copy.yml' + } + + } + } +} diff --git a/Jenkins-appnew b/Jenkins-appnew new file mode 100644 index 0000000000..3f2b3511ad --- /dev/null +++ b/Jenkins-appnew @@ -0,0 +1,46 @@ +pipeline{ + agent any + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + + stages{ + stage('Maven Build'){ + steps{ + echo "${getLatestCommitId()}" + sh "mvn clean package" + } + } + + stage('Docker Build Image'){ + steps{ + sh "docker build . -t prashanthi2021/qa:${getLatestCommitId()}" + } + } + + stage('push to docker hub'){ + steps{ + withCredentials([string(credentialsId: 'docker-hub', variable: 'dockerPwd')]) { + sh "docker login -u prashanthi2021 -p ${dockerPwd}" + sh "docker push prashanthi2021/qa:${getLatestCommitId()}" + } + + } + } + + stage('dev-deploy'){ + steps{ + sshagent(['docker-dev']) { + sh "ssh -o StrictHostKeyChecking=no ec2-user@172.31.1.118 docker rm -f mywebapp" + sh "ssh -o StrictHostKeyChecking=no ec2-user@172.31.1.118 docker run -d -p 8080:8080 --name mywebapp prashanthi2021/qa:${getLatestCommitId()}" + } + } + } + } +} +} +} + + diff --git a/Jenkins-decdemo b/Jenkins-decdemo new file mode 100644 index 0000000000..032870a253 --- /dev/null +++ b/Jenkins-decdemo @@ -0,0 +1,17 @@ +pipeline{ + agent any + stages{ + stage("GIT checkout"){ + steps{ + git credentialsId: 'javahome', url: 'https://github.com/srinivas1987devops/myweb.git' + + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean package" + sh "mv target/*.war target/myweb.war" + } + } + } +} diff --git a/Jenkins-decnew b/Jenkins-decnew new file mode 100644 index 0000000000..4af0e02158 --- /dev/null +++ b/Jenkins-decnew @@ -0,0 +1,35 @@ +pipeline{ + agent any + + environment{ + PATH = "/opt/maven3/bin:$PATH" + } + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean package" + sh "mv target/*.war target/myweb.war" + } + } + stage("deploy-dev"){ + steps{ + sshagent(['tomcat-new']) { + sh """ + scp -o StrictHostKeyChecking=no target/myweb.war ec2-user@172.31.10.233:/home/ec2-user/apache-tomcat-9.0.64/webapps/ + + ssh ec2-user@172.31.10.233 /home/ec2-user/apache-tomcat-9.0.64/bin/shutdown.sh + + ssh ec2-user@172.31.10.233 /home/ec2-user/apache-tomcat-9.0.64/bin/startup.sh + + """ + } + + } + } + } +} diff --git a/Jenkins-docker b/Jenkins-docker new file mode 100644 index 0000000000..38f3c26450 --- /dev/null +++ b/Jenkins-docker @@ -0,0 +1,59 @@ +pipeline{ + agent any + tools { + maven 'Maven-3.6.1' + } + + environment{ + PATH = "/opt/maven3/bin:$PATH" + } + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean sonar:sonar package" + + } + } + stage('Upload War To Nexus'){ + steps{ + nexusArtifactUploader artifacts: [ + [ + artifactId: 'myweb', + classifier: '', + file: "target/myweb-8.2.0.war", + type: 'war' + ] + ], + credentialsId: 'nexus3', + groupId: 'in.javahome', + nexusUrl: '172.31.36.181:8081', + nexusVersion: 'nexus3', + protocol: 'http', + repository: 'sample-releases', + version: '8.2.0' + } + } + stage('Build Docker Image'){ + steps{ + sh 'docker build -t deepikac2021/spring-boot-mongo .' + sh 'docker build -t tomcat:${BUILD_NUMBER} .' + sh 'docker run -itd --name srini36 -p 2900:8080 tomcat:${BUILD_NUMBER}' + } + } + stage('Push Docker Image'){ + steps{ + withCredentials([string(credentialsId: 'DOCKER_HUB_CREDENTIALS', variable: 'DOCKER_HUB_CREDENTIALS')]) { + sh "docker login -u deepikac2021 -p ${DOCKER_HUB_CREDENTIALS}" + } + sh 'docker push deepikac2021/spring-boot-mongo' + } + } + + + } +} diff --git a/Jenkins-kube b/Jenkins-kube new file mode 100644 index 0000000000..6054279b75 --- /dev/null +++ b/Jenkins-kube @@ -0,0 +1,65 @@ +pipeline{ + agent any + tools { + maven 'Maven-3.6.1' + } + + environment{ + PATH = "/opt/maven3/bin:$PATH" + } + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean sonar:sonar package" + + } + } + stage('Upload War To Nexus'){ + steps{ + nexusArtifactUploader artifacts: [ + [ + artifactId: 'myweb', + classifier: '', + file: "target/myweb-8.2.0.war", + type: 'war' + ] + ], + credentialsId: 'nexus3', + groupId: 'in.javahome', + nexusUrl: '172.31.16.243:8081', + nexusVersion: 'nexus3', + protocol: 'http', + repository: 'sample-releases', + version: '8.2.0' + } + } + stage('Build Docker Image'){ + steps{ + sh 'docker build -t deepikac2021/spring-boot-mongo .' + } + } + stage('Push Docker Image'){ + steps{ + withCredentials([string(credentialsId: 'DOCKER_HUB_CREDENTIALS', variable: 'DOCKER_HUB_CREDENTIALS')]) { + sh "docker login -u deepikac2021 -p ${DOCKER_HUB_CREDENTIALS}" + } + sh 'docker push deepikac2021/spring-boot-mongo' + } + } + stage("Deploy To Kuberates Cluster"){ + steps{ + kubernetesDeploy( + configs: 'springBoot.yml', + kubeconfigId: 'KUBERNETES_CLUSTER_CONFIG', + enableConfigSubstitution: true + ) + } + } + + } +} diff --git a/Jenkins-sonar-nexus-tomcat b/Jenkins-sonar-nexus-tomcat new file mode 100644 index 0000000000..ea9402c1e9 --- /dev/null +++ b/Jenkins-sonar-nexus-tomcat @@ -0,0 +1,57 @@ +pipeline{ + agent any + tools { + maven 'Maven-3.6.1' + } + + environment{ + PATH = "/opt/maven3/bin:$PATH" + } + stages{ + stage("Git Checkout"){ + steps{ + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage("Maven Build"){ + steps{ + sh "mvn clean sonar:sonar package" + + } + } + stage('Upload War To Nexus'){ + steps{ + nexusArtifactUploader artifacts: [ + [ + artifactId: 'myweb', + classifier: '', + file: "target/myweb-8.2.0.war", + type: 'war' + ] + ], + credentialsId: 'nexus3', + groupId: 'in.javahome', + nexusUrl: '172.31.40.8:8081', + nexusVersion: 'nexus3', + protocol: 'http', + repository: 'sample-releases', + version: '8.2.0' + } + } + stage("deploy-dev"){ + steps{ + sshagent(['tomcat-new']) { + sh """ + scp -o StrictHostKeyChecking=no target/myweb-8.2.0.war ec2-user@172.31.41.172:/home/ec2-user/apache-tomcat-9.0.64/webapps/ + + ssh ec2-user@172.31.41.172 /home/ec2-user/apache-tomcat-9.0.64/bin/shutdown.sh + + ssh ec2-user@172.31.41.172 /home/ec2-user/apache-tomcat-9.0.64/bin/startup.sh + + """ + } + + } + } + } +} diff --git a/Jenkins-terraform b/Jenkins-terraform new file mode 100644 index 0000000000..75456cf2b8 --- /dev/null +++ b/Jenkins-terraform @@ -0,0 +1,41 @@ +pipeline { + + parameters { + string(name: 'environment', defaultValue: 'prod', description: 'Workspace/Environment file to use for deployment') + string(name: 'region', defaultValue: 'ap-northeast-1', description: 'Workspace/region file to use for deployment') + + + } + agent any + stages { + stage('Download terraform code from Gihub') { + steps { + git credentialsId: 'javahome2', url: 'https://github.com/srinivas1987devops/myweb.git' + } + } + stage('Terraform Ininitialization') { + steps { + sh """ + cd /var/lib/jenkins/workspace/terraform + terraform init -reconfigure + """ + } + } + stage('Terraform Plan') { + steps { + sh """ + cd /var/lib/jenkins/workspace/terraform + terraform plan -out=plan.${BUILD_NUMBER} -var profile=${params.environment} -var region=${params.region} + """ + } + } + stage('Terraform Apply') { + steps { + sh """ + cd /var/lib/jenkins/workspace/terraform + terraform apply plan.${BUILD_NUMBER} + """ + } + } + } +} diff --git a/Jenkinsfile007 b/Jenkinsfile007 new file mode 100644 index 0000000000..c6f3cdbfc3 --- /dev/null +++ b/Jenkinsfile007 @@ -0,0 +1,3 @@ + +pipeline{ + diff --git a/copy.yml b/copy.yml new file mode 100644 index 0000000000..9b92da5ccf --- /dev/null +++ b/copy.yml @@ -0,0 +1,7 @@ +--- + - hosts: webservers + tasks: + - name: copy the file from local to remote + copy: + src: target/myweb-8.2.0.war + dest: /usr/local/apache-tomcat-9.0.64/webapps/ diff --git a/dev.in b/dev.in new file mode 100644 index 0000000000..0fe5f282bd --- /dev/null +++ b/dev.in @@ -0,0 +1,2 @@ +[webservers] +172.31.47.191 ansible_user=ec2-user diff --git a/kuberneeteswork b/kuberneeteswork new file mode 100644 index 0000000000..c62c831dbf --- /dev/null +++ b/kuberneeteswork @@ -0,0 +1 @@ +This is containeriztion and archestration tool diff --git a/main.tf b/main.tf new file mode 100644 index 0000000000..421856d9d5 --- /dev/null +++ b/main.tf @@ -0,0 +1,13 @@ +# Configure the AWS Provider +provider "aws" { + region = var.region + profile = var.profile +} +resource "aws_instance" "web7" { + ami = "${lookup(var.ami, var.region)}" + instance_type = "${lookup(var.instancetype, var.region)}" + + tags = { + Name = "HelloWorld9" + } +} diff --git a/pom.xml b/pom.xml index 51e2ea22c5..08a12c31d2 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,9 @@ kammana - + http://18.181.164.81:9000/ + + @@ -26,12 +28,12 @@ nexusRepo - http://13.233.230.166:8081/repository/maven-snapshots/ + http://54.178.74.89:8081/repository/sample-snapshots/ nexusRepo - http://13.233.230.166:8081/repository/maven-releases/ + http://54.178.74.89:8081/repository/sample-releases/ diff --git a/springBoot.yml b/springBoot.yml new file mode 100644 index 0000000000..8eec0608d5 --- /dev/null +++ b/springBoot.yml @@ -0,0 +1,32 @@ +# Replication Controller for springapp +apiVersion: v1 +kind: ReplicationController +metadata: + name: spring-controller +spec: + replicas: 1 + selector: + app: springboot + template: + metadata: + labels: + app: springboot + spec: + containers: + - image: deepikac2021/spring-boot-mongo + name: springboot + ports: + - containerPort: 8080 +--- +# Node Port Service For SpringApp +apiVersion: v1 +kind: Service +metadata: + name: springboot +spec: + type: NodePort + ports: + - port: 8080 + targetPort: 8080 + selector: + app: springboot diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 137aa6a6c2..9f88c1f963 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -2,6 +2,6 @@ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > - + Archetype Created Web Application diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 9139a2c9d9..3087892497 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,5 +1,5 @@ -

JavaHome App Version-17

+

GANA TECH APP VERSION-26000

diff --git a/var.tf b/var.tf new file mode 100644 index 0000000000..65482ca136 --- /dev/null +++ b/var.tf @@ -0,0 +1,20 @@ +variable "region" { + type = string +} +variable "profile" { + type = string +} +variable "ami" { + type = map + default = { + ap-northeast-1 = "ami-0218d08a1f9dac831" + us-east-2 = "ami-002068ed284fb165b" + } +} +variable "instancetype" { + type = map + default = { + ap-northeast-1 = "t2.micro" + us-east-2 = "t3.micro" + } +} diff --git a/vasu.xml b/vasu.xml new file mode 100644 index 0000000000..d80e789f11 --- /dev/null +++ b/vasu.xml @@ -0,0 +1,39 @@ + + 4.0.0 + in.javahome + myweb + war + 8.2.0 + Java Home myweb + http://maven.apache.org + + + kammana + http://54.65.244.211:9000/ + + + + + + + junit + junit + 3.8.1 + test + + + + + + + + + maven1 + Maven.org + http://repo1.maven.org/maven2 + + + + +