Skip to content

Commit

Permalink
Create sonar-status-check
Browse files Browse the repository at this point in the history
  • Loading branch information
javahometech authored Apr 17, 2018
1 parent a028272 commit 363d33e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions sonar-status-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
node{
stage('SCM Checkout'){
git 'https://github.com/javahometech/my-app'
}
stage('Compile-Package'){
// Get maven home path
def mvnHome = tool name: 'maven-3', type: 'maven'
sh "${mvnHome}/bin/mvn package"
}

stage('SonarQube Analysis') {
def mvnHome = tool name: 'maven-3', type: 'maven'
withSonarQubeEnv('sonar-6') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
}

stage("Quality Gate Statuc Check"){
timeout(time: 1, unit: 'HOURS') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
slackSend baseUrl: 'https://hooks.slack.com/services/',
channel: '#jenkins-pipeline-demo',
color: 'danger',
message: 'SonarQube Analysis Failed',
teamDomain: 'javahomecloud',
tokenCredentialId: 'slack-demo'
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}

stage('Email Notification'){
mail bcc: '', body: '''Hi Welcome to jenkins email alerts
Thanks
Hari''', cc: '', from: '', replyTo: '', subject: 'Jenkins Job', to: '[email protected]'
}
stage('Slack Notification'){
slackSend baseUrl: 'https://hooks.slack.com/services/',
channel: '#jenkins-pipeline-demo',
color: 'good',
message: 'Welcome to Jenkins, Slack!',
teamDomain: 'javahomecloud',
tokenCredentialId: 'slack-demo'
}

}

0 comments on commit 363d33e

Please sign in to comment.