diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..15c5273b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:16.04 +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y curl && \ + apt-get install -y software-properties-common && \ + add-apt-repository ppa:webupd8team/java -y && \ + apt-get update && \ + echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ + apt-get install -y openjdk-8-jdk && \ + apt-get clean +RUN groupadd tomcat +RUN useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat +RUN cd /tmp +RUN curl -O https://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.69/bin/apache-tomcat-8.5.69.tar.gz +RUN mkdir /opt/tomcat +RUN gzip -V +RUN tar -xvzf apache-tomcat-8.5.69.tar.gz -C /opt/tomcat --strip-components=1 +RUN cd /opt/tomcat +RUN chgrp -R tomcat /opt/tomcat +ADD target/myapp.war /opt/tomcat/webapps +#RUN chown -R tomcat conf/ webapps/ work/ temp/ logs/ +#RUN update-java-alternatives -l +ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 +Run cd /opt/tomcat/bin +expose 8080 +#CMD /opt/tomcat/bin/catalina.sh run && tail -f /opt/tomcat/logs/catalina.out +CMD ["/opt/tomcat/bin/catalina.sh", "run"] diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..e1c3c83e --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,32 @@ +pipeline { + node { label "$NODE" } + parameters { + // gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH' + // parameters { string(name: 'NODE', defaultValue: 'some_node', description: '') } + gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH',string(name: 'NODE', defaultValue: 'master', description: '') + + } + stages { + stage('Checkout') { + steps { + git branch: "${params.BRANCH}", url: 'https://github.com/csenapati12/java-tomcat-maven-docker.git' + + } + } + stage('Build and Package') { + steps { + + script{ + sh """ + ls + # mvn clean package + echo "MAster" + ls -la + """ + } + + } + } + + } +} diff --git a/Jenkinsfile-back b/Jenkinsfile-back new file mode 100644 index 00000000..bfbce308 --- /dev/null +++ b/Jenkinsfile-back @@ -0,0 +1,21 @@ +node(){ +checkout scm + + stage('compile') { + echo "compile" + } + stage('test') { + echo "test" + } + +stage('Maven Build') { + + } + stage('deploy to nexus') { + echo "deploy" + } + +stage('Docker Build') { + echo "Docker build" + } + } diff --git a/Jenkinsfile-docker b/Jenkinsfile-docker new file mode 100644 index 00000000..8c4847c2 --- /dev/null +++ b/Jenkinsfile-docker @@ -0,0 +1,26 @@ +node(){ +checkout scm + stage('Code build'){ + sh "mvn package" + } + stage('Docker build and start'){ + sh ''' + + docker build -t testimage . + docker run --name=newcontainer -d -p 9898:8080 testimage + ''' + } + stage('Smoke testing and result'){ + echo "smoke testing" + } + + stage('Docker build and start'){ + sh ''' + docker stop newcontainer + docker rm -f newcontainer + docker rmi testimage + + ''' + } + +} diff --git a/Jenkinsfile-latest b/Jenkinsfile-latest new file mode 100644 index 00000000..3adb3dfb --- /dev/null +++ b/Jenkinsfile-latest @@ -0,0 +1,25 @@ +pipeline{ + agent any + stages{ + stage("checkout"){ + steps{ + checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/csenapati12/java-tomcat-maven-docker.git']]] + } + } + stage("Build and packaging"){ + steps{ + sh """ + mvn clean package + """ + } + } + stage("Deploy tomcat"){ + steps{ + script{ + ansiblePlaybook credentialsId: 'root-credentials', inventory: 'ansible-hosts', playbook: 'deploytomcat.yml' + } + } + } + } + +} diff --git a/Jenkinsfile-new b/Jenkinsfile-new new file mode 100644 index 00000000..b4685813 --- /dev/null +++ b/Jenkinsfile-new @@ -0,0 +1,21 @@ +pipeline { + + agent any + parameters { + choice choices: ['DeployL1_L2_L3', 'L4', 'L6'], description: 'Please select the environment to Deploy!!!', name: 'ENV_NAME' + choice choices: ['HSVALIDATION_BUSINESS_SERVICE', 'HSVALIDATION_DATA_SERVICE'], description: 'Please select the application!!!', name: 'APP_NAME' + choice choices: ['HSVALIDATION_BUSINESS_SERVICE1', 'HSVALIDATION_DATA_SERVICE2'], description: 'Please select the application!!!', name: 'APP_NAME' +} + stages { + + stage('Code checkout') { + when { + expression { params.ENV_NAME =='DeployL1_L2_L3'} + } + steps { + echo "helllo" + } + } + + } + } diff --git a/README.md b/README.md index de9dd576..df1fe709 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ +//added new line for test pull SCM +//added new line for test pull SCM--->22ndfeb +//test multibranch # java-tomcat-maven-example - +#adding devops This is an example ready-to-deploy java web application built for Tomcat using Maven and webapp-runner. ## Running Locally @@ -23,6 +26,7 @@ The application will be available on `http://localhost:8080`. 2. Add the webapp-runner plugin into the `pom.xml`: +Test merge ``` diff --git a/ansible-hosts b/ansible-hosts new file mode 100644 index 00000000..d385e974 --- /dev/null +++ b/ansible-hosts @@ -0,0 +1,4 @@ +[deploy-tomcat] +#34.122.68.73 +35.238.183.82 +130.211.221.35 diff --git a/deployfile.yml b/deployfile.yml new file mode 100644 index 00000000..15ff8045 --- /dev/null +++ b/deployfile.yml @@ -0,0 +1,8 @@ +--- +- hosts: localhost + become: true + become_user: root + tasks: + - name: Copy the playbook + copy: src=/var/lib/jenkins/workspace/ansible-pipleline/target/myapp.war dest=/home/skylab_priyadarshini/tomcat8/webapps + diff --git a/deploytomcat.yml b/deploytomcat.yml new file mode 100644 index 00000000..5fa6dd34 --- /dev/null +++ b/deploytomcat.yml @@ -0,0 +1,7 @@ +--- +- hosts: deploy-tomcat + become: true + become_user: root + tasks: + - name: Copy the artifact + copy: src=/var/lib/jenkins/workspace/ansible-pipleline/target/myapp.war dest=/home/tomcat/apache-tomcat-8.5.64/webapps diff --git a/pom.xml b/pom.xml index 8e60eb85..089225e2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,19 +4,19 @@ com.example java-tomcat-maven-example war - 1.0-SNAPSHOT + 5.0.1-SNAPSHOTS hello Maven Webapp http://maven.apache.org junit junit - 3.8.1 + 4.3 test - java-tomcat-maven-example + myapp org.apache.maven.plugins @@ -41,4 +41,16 @@ + + + releases + + http://34.133.198.104:8081/repository/maven-releases/ + + + snapshots + + http://34.133.198.104:8081/repository/maven-snapshots/ + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index c38169bb..eb7ca2a1 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,5 +1,10 @@ - -

Hello World!

+ + +

Welcome To

+

Test App

+

!!!!!!!!!!!!!!!!!!15th Aug ?????????!!!!!!!!!!!!!!!!!!!!!!!!

+

+