Skip to content

Commit

Permalink
Create Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
devopstrainingblr authored Mar 27, 2024
1 parent bf9bfb6 commit b7c1188
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
pipeline{

agent any

tools{
maven 'maven3.9.6'
}

//Checkout code
stages{
stage('CheckOuteCode'){
steps{
sendSlackNotifications("STARTED")
git branch: 'development', credentialsId: 'f4d44680-6f7c-4889-b836-5ce7015057f8', url: 'https://github.com/MithunTechnologiesDevOps/maven-web-application.git'
}
}
//Build
stage('Build'){
steps{
sh "mvn clean package"
}
}
/*
//Execute SonarQube Report
stage('ExecuteSonarQubeReport'){
steps{
sh "mvn clean sonar:sonar"
}
}
// Upload Artifcats into Nexus
stage('UploadArtifcatsIntoNexus'){
steps{
sh "mvn clean deploy"
}
}
//Deploy App into Tomcat Server
stage('DeployAppIntoTomcat'){
steps{
sshagent(['ea56a0ef-94e7-43c1-99e3-d7e0947043a3']) {
sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war [email protected]:/opt/apache-tomcat-9.0.86/webapps/"
}
}
}
*/
}//stages closing

post {
success {
sendSlackNotifications(currentBuild.result)
}
failure {
sendSlackNotifications(currentBuild.result)
}
}
}//pipeline closing


def sendSlackNotifications(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'

// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"

// Override default values based on build status
if (buildStatus == 'STARTED') {
colorName = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESS') {
colorName = 'GREEN'
colorCode = '#00FF00'
} else {
colorName = 'RED'
colorCode = '#FF0000'
}

// Send notifications
slackSend (color: colorCode, message: summary, channel: "citibank-project")
}



0 comments on commit b7c1188

Please sign in to comment.