diff --git a/MPJenkinsFile b/MPJenkinsFile new file mode 100644 index 00000000..9c50b9fc --- /dev/null +++ b/MPJenkinsFile @@ -0,0 +1,111 @@ +pipeline { + agent any + + tools { + maven "maven 3.9.8" + } + + triggers { + githubPush() + // cron('*/5 * * * *') + // pollSCM('* * * * *') + } + + parameters + { + choice(name: 'branchNames', choices: ['master', 'dev', 'qa','f1'], description: 'Select the branch to build from') + } + + stages { + stage('Main Pipeline Execution') { + steps { + script { + try { + currentBuild.displayName = "#${BUILD_NUMBER} - ${params.branchNames}" + // Start Notification + notifyBuild('STARTED') + + // Git Checkout + stage('Git Checkout') { + git branch: params.branchNames, credentialsId: '6af083e0-dcd0-4ed5-bb9c-53952b6f3b23', url: 'https://github.com/mail2spd04/KKweb-project-kkfunda.git' + } + + // Compile + stage('Compile') { + sh "mvn clean compile" + } + + // Build + stage('Build') { + sh "mvn package" + } + + // SonarQube + stage('SonarQube') { + sh "mvn sonar:sonar" + } + + // Deploy to Nexus + stage('Deploy to Nexus') { + sh "mvn deploy" + } + + // Deploy to Tomcat + stage('Deploy to Tomcat') { + sh """ + curl -u sairhel:password \ + --upload-file /var/lib/jenkins/workspace/dPipeLineTry/target/maven-web-application.war \ + "http://52.66.248.84:8080/manager/text/deploy?path=/maven-Dweb-application&update=true" + """ + } + + currentBuild.result = 'SUCCESS' + + } catch (err) { + currentBuild.result = 'FAILURE' + echo "Error occurred: ${err}" + throw err + } finally { + echo "Running final cleanup..." + notifyBuild(currentBuild.result) + } + } + } + } + } + + post { + success { + script { + notifyBuild(currentBuild.result) + } + } + failure { + script { + notifyBuild(currentBuild.result) + } + } + } +} + +def notifyBuild(String buildStatus = 'STARTED') { + buildStatus = buildStatus ?: 'SUCCESS' + + def colorCode = '#FF0000' // default to red + + def subject = "${buildStatus}: Job '${env.JOB_NAME}' [${env.BUILD_NUMBER}]" + def summary = "${subject} (${env.BUILD_URL})" + + switch (buildStatus) { + case 'STARTED': + colorCode = '#FFFF00' // Yellow + break + case 'SUCCESS': + colorCode = '#00FF00' // Green + break + default: + colorCode = '#FF0000' // Red + } + + slackSend(color: colorCode, message: summary, channel: '#new-maven') +} diff --git a/pom.xml b/pom.xml index 440d6283..c8d018bd 100644 --- a/pom.xml +++ b/pom.xml @@ -5,25 +5,31 @@ com.kk maven-web-application-kkfunda war - 0.0.1-SNAPSHOT + 1.2.0-SNAPSHOT + maven-web-application Maven Web Project for Java Project - KK FUNDA + KK FUNDA Test http://kkfunda.com - + 17 5.3.34 4.11 1.2.17 - http://15.207.54.73:8639/kkfunda/ - admin - password + http://13.234.202.150:9000 + + + squ_1d8139f01239a2fffd4f6d8ed38f2c8104a5e374 + UTF-8 UTF-8 @@ -84,12 +90,7 @@ - - javax.servlet - javax.servlet-api - 3.1.0 - provided - + @@ -98,13 +99,16 @@ nexus KK FUNDA Releases Nexus Repository - http://172.31.40.189:8081/repository/flipkart-release/ + + http://3.110.181.189:8081/repository/Jio-release/ + nexus - KK FUNDA Snapshot Nexus Repository - http://172.31.40.189:8081/repository/flipkart-snapshot/ + + http://3.110.181.189:8081/repository/Jio-snapshot/ + @@ -146,6 +150,14 @@ maven-web-application + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 4.0.0.4121 + +