Skip to content
Open

Qa #7

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions MPJenkinsFile
Original file line number Diff line number Diff line change
@@ -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')
}
42 changes: 27 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@
<groupId>com.kk</groupId>
<artifactId>maven-web-application-kkfunda</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<!--<version>1.3.0</version> -->

<name>maven-web-application</name>

<description>Maven Web Project for Java Project</description>

<organization>
<name>KK FUNDA</name>
<name>KK FUNDA Test</name>
<url>http://kkfunda.com</url>
</organization>

<properties>
<jdk.version>17</jdk.version>
<spring.version>5.3.34</spring.version>
<junit.version>4.11</junit.version>
<log4j.version>1.2.17</log4j.version>
<sonar.host.url>http://15.207.54.73:8639/kkfunda/</sonar.host.url>
<sonar.login>admin</sonar.login>
<sonar.password>password</sonar.password>
<sonar.host.url>http://13.234.202.150:9000</sonar.host.url>

<!--
<sonar.login>admin</sonar.login>
<sonar.password>sonar</sonar.password>
-->
<sonar.login>squ_1d8139f01239a2fffd4f6d8ed38f2c8104a5e374</sonar.login>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

Expand Down Expand Up @@ -84,12 +90,7 @@

<!-- provided dependencies -->

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>


</dependencies>

Expand All @@ -98,13 +99,16 @@
<repository>
<id>nexus</id>
<name>KK FUNDA Releases Nexus Repository</name>
<url>http://172.31.40.189:8081/repository/flipkart-release/</url>

<url>http://3.110.181.189:8081/repository/Jio-release/</url>

</repository>

<snapshotRepository>
<id>nexus</id>
<name>KK FUNDA Snapshot Nexus Repository </name>
<url>http://172.31.40.189:8081/repository/flipkart-snapshot/</url>

<url>http://3.110.181.189:8081/repository/Jio-snapshot/</url>

</snapshotRepository>

</distributionManagement>
Expand Down Expand Up @@ -146,6 +150,14 @@
<wtpContextName>maven-web-application</wtpContextName>
</configuration>
</plugin>


<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.0.0.4121</version>
</plugin>


</plugins>
</build>
Expand Down