forked from matteosusca/po-test-json-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
69 lines (69 loc) · 2.2 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
pipeline {
agent {
docker {
image 'iubar-java-alpine:jdk11'
label 'docker'
args '-v ${HOME}/.m2:/home/jenkins/.m2:rw,z -v ${HOME}/.sonar:/home/jenkins/.sonar:rw,z'
}
}
options {
ansiColor('xterm')
}
environment {
MAVEN_ARGS = '--show-version --batch-mode'
MAVEN_OPTS = '-Djava.awt.headless=true'
}
stages {
stage('Build') {
steps {
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS clean compile'
}
}
stage('Test') {
steps {
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS test'
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Quality') {
when {
not {
environment name: 'SKIP_SONARQUBE', value: 'true'
}
}
steps {
sh '''
sonar-scanner
wget --user=${ARTIFACTORY_USER} --password=${ARTIFACTORY_PASS} http://192.168.0.119:8082/artifactory/iubar-repo-local/jenkins/jenkins-sonar-quality-gate-check.sh --no-check-certificate
chmod +x ./jenkins-sonar-quality-gate-check.sh
./jenkins-sonar-quality-gate-check.sh false # true / false = Ignore or not the quality gate score
'''
}
}
stage('Deploy') {
steps {
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS -DskipTests deploy'
}
}
}
post {
success {
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS dependency:analyze'
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS versions:display-plugin-updates'
sh 'mvn $MAVEN_ARGS $MAVEN_OPTS versions:display-dependency-updates'
}
always { // oppure utilizzare changed
sh "curl -H 'JENKINS: Pipeline Hook Iubar' -i -X GET -G ${env.IUBAR_WEBHOOK_URL} -d status=${currentBuild.currentResult} -d job_name='${JOB_NAME}' -d build_number='${BUILD_NUMBER}'"
}
cleanup {
cleanWs()
dir("${WORKSPACE}@tmp") {
deleteDir()
}
}
}
}