0% found this document useful (0 votes)
22 views2 pages

PAAC CI SlackNotification

Uploaded by

Melki Meryem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

PAAC CI SlackNotification

Uploaded by

Melki Meryem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

def COLOR_MAP = [

'SUCCESS': 'good',
'FAILURE': 'danger',
]
pipeline {
agent any
tools {
maven "MAVEN3"
jdk "OracleJDK8"
}

stages{
stage('Print error'){
steps{
sh 'fake comment'
}
}
stage('Fetch code') {
steps{
git branch: 'vp-rem', url:'https://github.com/devopshydclub/vprofile-
repo.git'
}
}

stage('Build') {
steps {
sh 'mvn clean install -DskipTests'
}
post {
success {
echo "Now Archiving."
archiveArtifacts artifacts: '**/*.war'
}
}
}
stage('Test'){
steps {
sh 'mvn test'
}

stage('Checkstyle Analysis'){
steps {
sh 'mvn checkstyle:checkstyle'
}
}

stage('Sonar Analysis') {
environment {
scannerHome = tool 'sonar4.7'
}
steps {
withSonarQubeEnv('sonar') {
sh '''${scannerHome}/bin/sonar-scanner -
Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/
controllerTest/ \
-Dsonar.junit.reportsPath=target/surefire-reports/ \
-Dsonar.jacoco.reportsPath=target/jacoco.exec \
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-
result.xml'''
}
}
}

stage("Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
// Parameter indicates whether to set pipeline to UNSTABLE if
Quality Gate fails
// true = set pipeline to UNSTABLE, false = don't
waitForQualityGate abortPipeline: true
}
}
}

stage("UploadArtifact"){
steps{
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: '172.31.18.28:8081',
groupId: 'QA',
version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
repository: 'vprofile-repo',
credentialsId: 'nexuslogin',
artifacts: [
[artifactId: 'vproapp',
classifier: '',
file: 'target/vprofile-v2.war',
type: 'war']
]
)
}
}
}
post {
always {
echo 'Slack Notifications.'
slackSend channel: '#jenkinscicd',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME}
build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
}
}

You might also like