diff --git a/Assi7Jenk b/Assi7Jenk new file mode 100644 index 0000000..dd11971 --- /dev/null +++ b/Assi7Jenk @@ -0,0 +1,83 @@ +pipeline { + agent{label 'master'} + parameters { + string defaultValue: 'Hari', name: 'var1' + choice choices: ['Dev', 'Test', 'Prod'], description: 'Select a Choice Parameter', name: 'var2' + booleanParam defaultValue: true, name: 'var3' + } + triggers{ + cron 'H * * * *' + pollSCM 'H * * * *' + } + environment { + AWS_ACCESS_KEY=credentials('aws_access_key') + GITHUB_CRED=credentials('Lavi') + SSH_CRED=credentials('ssh_key') + My_String="${params.var1}" + My_Choice="${params.var2}" + My_Boolean="${params.var3}" + } + stages { + stage('checkout') { + + when{ + anyOf{ + branch 'main' + branch 'Dev' + } + } + steps { + git branch: 'main', url: 'https://github.com/HariGangaiah/java-example.git' + echo "Checking the trigger" + } + } + stage('Test') { + + steps { + echo 'Running unit test and integration test' + echo "Environment Variable MY_STRING: ${My_String}" + echo "Environment Variable MY_CHOICE: ${My_Choice}" + echo "Environment Variable MY_BOOLEAN: ${My_Boolean}" + } + } + stage('Build and Global Variables') { + + when { + expression { + (currentBuild.result == null || currentBuild.result == 'SUCCESS') + } + } + steps { + echo "jobname:: '$JOB_NAME'" + echo "build no:: '$BUILD_NUMBER'" + echo "job URL:: '$BUILD_URL'" + echo "Jenkins URL:: '$JENKINS_URL'" + } + } + stage('Push') { + + when { + expression { + (currentBuild.result == null || currentBuild.result == 'SUCCESS') + } + } + steps { + echo 'Pusing artifact to artifactory' + sh 'echo $AWS_ACCESS_KEY' + sh 'echo USERNAME:PASSWORD:: $GITHUB_CRED' + sh 'echo username: $GITHUB_CRED_USR' + sh 'echo password: $GITHUB_CRED_PSW' + } + } + } + post { + always { + emailext body: ''' + jobname : '$JOB_NAME' + build no: '$BUILD_NUMBER' + job URL: '$BUILD_URL' + build status: '$BUILD_STATUS' + ''', subject: '$JOB_NAME' , from: 'jenkins@example.com', to:'harigangaiah01@gmail.com' + } + } +} diff --git a/Dockerfile b/Dockerfile index 0966445..b58117a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,14 @@ -FROM maven:amazoncorretto as build -WORKDIR /javaapp -COPY . . +FROM ubuntu AS st1 +RUN apt update && apt install git -y && apt-get clean +RUN git clone https://github.com/HariGangiah/java-example.git +WORKDIR /java-example + +FROM maven:amazoncorretto AS st2 +WORKDIR /app +COPY --from=st1 /java-example . RUN mvn clean install -FROM adhig93/tomcat-conf -COPY --from=build /javaapp/target/*.war /usr/local/tomcat/webapps/ +FROM artisantek/tomcat:1 +COPY --from=st2 /app/target/*.war /usr/local/tomcat/webapps/ +EXPOSE 9050 +CMD ["catalina.sh", "run"] diff --git a/pom-java17.xml b/pom-java17.xml deleted file mode 100644 index f7eacb3..0000000 --- a/pom-java17.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - works.buddy.samples - works-with-heroku - 1.0 - war - - - - 17 - 17 - - - - - javax.servlet - servlet-api - 2.5 - provided - - - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 3.12.4 - test - - - - - - - org.apache.maven.plugins - maven-war-plugin - 3.3.1 - - - org.apache.maven.plugins - maven-dependency-plugin - 3.4.0 - - - package - copy - - - - org.eclipse.jetty - jetty-runner - 9.3.3.v20150827 - jetty-runner.jar - - - - - - - - - diff --git a/pom.xml b/pom.xml index 7f5d8b9..f7eacb3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,10 +6,13 @@ works-with-heroku 1.0 war + + - 1.6 - 1.6 + 17 + 17 + javax.servlet @@ -25,18 +28,23 @@ org.mockito - mockito-all - 1.10.19 + mockito-core + 3.12.4 test - + + + org.apache.maven.plugins + maven-war-plugin + 3.3.1 + org.apache.maven.plugins maven-dependency-plugin - 2.3 + 3.4.0 package diff --git a/test b/test index eb58ad5..54cecb1 100644 --- a/test +++ b/test @@ -1 +1,3 @@ -Checking POLL SCM +echo "Changes Configured" +echo "Checking for the trigger after jenkins URL changed" +hari