diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..e872c97f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,83 @@ +pipeline { + agent any + stages { + stage('build') { + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } + + } + steps { + echo 'compiling sysfoo app...' + sh 'mvn compile' + } + } + + stage('test') { + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } + + } + steps { + echo 'running unit tests....' + sh 'mvn clean test' + } + } + stage ('running tests parallel'){ +parallel{ + stage('package') { + + agent { + docker { + image 'maven:3.6.3-jdk-11-slim' + } +} + + steps { + script { + if (env.BRANCH_NAME == 'master'){ + echo 'generating artifact....' + sh 'mvn package -DskipTests' + archiveArtifacts 'target/*.war' + } else { + echo 'This is not master branch'} + + } + } +} + stage('Docker BnP.') { + agent any + steps { + script { + if (env.BRANCH_NAME == 'master'){ + docker.withRegistry('https://index.docker.io/v1/', 'dockerlogin') { + def dockerImage = docker.build("mohammedimrantk/sysfoo:v${env.BUILD_ID}", "./") + dockerImage.push() + dockerImage.push("latest") + dockerImage.push("dev") + } + }else { + echo 'This is not master branch'} + } + } + } + +} +} + } + + + tools { + maven 'Maven 3.6.3' + } + post { + always { + echo 'This pipeline is completed..' + } + + } +} + diff --git a/README.md b/README.md index 38a78cde..95c3e0ac 100644 --- a/README.md +++ b/README.md @@ -1 +1,7 @@ This is a Sample Maven App. +changed this readme, to test the jenkins app +again changed to check the git +updated this file to test scan option +this is ti create new branch and pull request +test this branching again +test this with permissions diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..ebc29d92 --- /dev/null +++ b/dockerfile @@ -0,0 +1,9 @@ +FROM maven:3.6.3-jdk-11-slim as build +WORKDIR /opt/demo +COPY . /opt/demo +RUN mvn package -DskipTests + +FROM tomcat:jre8-openjdk-slim-buster as run +WORKDIR /usr/local/tomcat +COPY --from=build /opt/demo/target/sysfoo.war webapps/ROOT.war + diff --git a/test.md b/test.md new file mode 100644 index 00000000..e69de29b