diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..dfc2f31e5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,111 @@ +pipeline{ + tools{ + jdk 'myjava' + maven 'mymaven1' + } + environment { + + registry = "mohitkhokhar172/sample" + + registryCredential = 'devopslearner45' + + dockerImage = '' + + } + agent none + stages{ + stage('Checkout'){ + agent any + steps{ + git 'https://github.com/devops-trainer/DevOpsClassCodes.git' + } + } + stage('Compile'){ + agent any + steps{ + sh 'mvn compile' + } + } + stage('CodeReview'){ + agent any + steps{ + sh 'mvn pmd:pmd' + } + } + stage('UnitTest'){ + agent any + steps{ + //git 'https://github.com/devops-trainer/DevOpsClassCodes.git' + sh 'mvn test' + } + } + stage('MetricCheck'){ + agent any + steps{ + sh 'mvn cobertura:cobertura -Dcobertura.report.format=xml' + } + } + stage('Package'){ + agent any + steps{ + sh 'mvn package' + } + } + + + + stage('Cloning our Git') { +agent any + steps { + + git 'https://github.com/mohitkhokhar172/DevOpsClassCodes.git' + + } + + } + + stage('Building our image') { +agent any + steps { + + script { + sh 'whoami' + dockerImage = docker.build registry + ":$BUILD_NUMBER" + + } + + } + + } + + stage('Deploy our image') { +agent any + steps { + + script { + + docker.withRegistry( '', registryCredential ) { + dockerImage.push() + } + + } + + } + + } + + stage('Cleaning up') { +agent any + steps { + + sh "docker rmi $registry:$BUILD_NUMBER" + + } + + } + + } + + + +} diff --git a/README.md b/README.md index cc0530089..11b3abe8a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Addressbook Tutorial1 ==================== - +making a change to this file This tutorial teaches you some of the basic concepts in [Vaadin Framework](https://vaadin.com). It is meant to be a fast read for learning how to get started - not an example on how application should be designed. Please note this example uses and requires Java 8 to work. diff --git a/addressbook.war b/addressbook.war new file mode 100644 index 000000000..7768854b0 Binary files /dev/null and b/addressbook.war differ diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..19a6f3834 --- /dev/null +++ b/dockerfile @@ -0,0 +1,4 @@ +FROM tomcat:9 +ADD addressbook.war /usr/local/tomcat/webapps/ +EXPOSE 8080 +CMD ["catalina.sh", "run"] diff --git a/multiStageDockerfile b/multiStageDockerfile new file mode 100644 index 000000000..ff2c7048f --- /dev/null +++ b/multiStageDockerfile @@ -0,0 +1,11 @@ +FROM maven:3.6.3-jdk-8 AS Build +RUN mkdir sample +WORKDIR sample +RUN git clone https://github.com/mohitkhokhar172/DevOpsClassCodes.git +RUN cd DevOpsClassCodes && mvn compile +RUN cd DevOpsClassCodes && mvn package + +FROM tomcat:9 +COPY --from=Build /sample/DevOpsClassCodes/target/addressbook.war /usr/local/tomcat/webapps +EXPOSE 8080 +CMD ["catalina.sh", "run"] diff --git a/multistagedockerfile b/multistagedockerfile new file mode 100644 index 000000000..65efa99eb --- /dev/null +++ b/multistagedockerfile @@ -0,0 +1,11 @@ +FROM maven:3.6.3-jdk-8 AS Build +RUN mkdir sample +WORKDIR sample +RUN git clone https://github.com/mohitkhokhar172/DevOpsClassCodes.git +RUN cd DevOpsClassCodes && mvn compile +RUN cd DevOpsClassCodes && mvn package + +FROM tomcat:9.0.8-jre8-alpine +COPY --from=Build /sample/DevOpsClassCodes/target/addressbook.war /usr/local/tomcat/webapps +EXPOSE 8080 +CMD ["catalina.sh", "run"] diff --git a/test_file b/test_file new file mode 100644 index 000000000..2ec81efef --- /dev/null +++ b/test_file @@ -0,0 +1,2 @@ +Test to check webhook +Making another change diff --git a/testwebhook b/testwebhook new file mode 100644 index 000000000..81b0c164d --- /dev/null +++ b/testwebhook @@ -0,0 +1 @@ +this change must trigger the build number 5 for the first project diff --git a/webhookfile b/webhookfile new file mode 100644 index 000000000..cd79e32c1 --- /dev/null +++ b/webhookfile @@ -0,0 +1,5 @@ +this change should trigger the compile project +this change must trigger the build number 6 +this change will not afftec jenkins +this should trigger build number 7 +this will trigger build 3