diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6be5503 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM tomcat:9.0 +COPY ./addressbook.war /usr/local/tomcat/webapps +RUN cp -r /usr/local/tomcat/webapps.dist/* /usr/local/tomcat/webapps diff --git a/Jenkinsfile b/Jenkinsfile index cc90075..6d562bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,23 @@ - pipeline{ tools{ - - maven 'mymaven' + jdk 'java' + maven 'maven' } agent any stages{ stage('Checkout'){ - - steps{ - echo 'cloning' - git 'https://github.com/Sonal0409/DevOpsClassCodes.git' + steps{ + echo 'cloning..' + git 'https://github.com/meregabriel/DevOpsCodeDemo.git' } } stage('Compile'){ - steps{ - echo 'complie the code..' + echo 'compiling..' sh 'mvn compile' } } stage('CodeReview'){ - steps{ echo 'codeReview' @@ -29,22 +25,20 @@ pipeline{ } } stage('UnitTest'){ - steps{ - + echo 'Testing' sh 'mvn test' } - + post { + success { + junit 'target/surefire-reports/*.xml' + } + } } - stage('Package'){ - steps{ - sh 'mvn package' } } - - } } diff --git a/Jenkinsfile1 b/Jenkinsfile1 new file mode 100644 index 0000000..42c6c79 --- /dev/null +++ b/Jenkinsfile1 @@ -0,0 +1,49 @@ + pipeline{ + tools{ + jdk 'myjava' + maven 'mymaven' + } + agent none + stages{ + stage('Checkout'){ + agent any + steps{ + echo 'cloning...' + git 'https://github.com/Sonal0409/DevOpsCodeDemo.git' + } + } + stage('Compile'){ + agent {label 'slave1'} + steps{ + echo 'compiling...' + sh 'mvn compile' + } + } + stage('CodeReview'){ + agent {label 'slave2'} + steps{ + + echo 'codeReview...' + sh 'mvn pmd:pmd' + } + } + stage('UnitTest'){ + agent {label 'slave2'} + steps{ + echo 'Testing' + sh 'mvn test' + } + post { + success { + junit 'target/surefire-reports/*.xml' + } + } + } + stage('Package'){ + agent any + steps{ + sh 'mvn package' + } + } + } + } diff --git a/Jenkinsfile4DockerPush b/Jenkinsfile4DockerPush new file mode 100644 index 0000000..bd7eb17 --- /dev/null +++ b/Jenkinsfile4DockerPush @@ -0,0 +1,49 @@ + +pipeline{ + + agent any + + //create dockerhub credential in github with your dockerhub Username and Password/Token + environment { + DOCKERHUB_CREDENTIALS=credentials('dockerhub') + } + + stages { + + stage('gitclone') { + + steps { + git 'https://github.com/theitern/DevOpsCodeDemo.git' + } + } + + stage('Build') { + steps { + + sh 'docker build -t akinaregbesola/private:${BUILD_NUMBER} .' + } + } + + stage('Login') { + + steps { + sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login --username akinaregbesola --password-stdin' + } + } + + stage('Push') { + + steps { + sh 'docker push akinaregbesola/private:${BUILD_NUMBER}' + } + } + } + + post { + always { + sh 'docker logout' + } + } + +} +