-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathJenkinsFile
More file actions
executable file
·67 lines (67 loc) · 2.1 KB
/
JenkinsFile
File metadata and controls
executable file
·67 lines (67 loc) · 2.1 KB
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
void setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/IF-090Java/eSchool"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "Unit tests an code analysis"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
pipeline{
agent any
stages{
stage('compile'){
steps{
withMaven(maven : 'maven3'){
sh 'mvn clean compile'
}
}
}
stage('test'){
steps{
withMaven(maven : 'maven3'){
sh 'mvn test -Dtest=!academy.softserve.eschool.*.*IntegrationTest'
}
}
}
stage('Sonar analysis'){
steps{
withMaven(maven : 'maven3'){
withSonarQubeEnv('sonar6'){
sh 'mvn sonar:sonar'
}
}
}
}
stage("Quality Gate"){
steps{
timeout(time: 5, unit: 'MINUTES') {
script{
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage("Build"){
steps{
withMaven(maven : 'maven3'){
sh 'mvn package -Dmaven.test.skip=true'
}
}
}
}
post {
always {
archiveArtifacts artifacts: '**/*.jar', onlyIfSuccessful: true
}
success {
setBuildStatus("Build succeeded", "SUCCESS");
}
failure {
setBuildStatus("Build failed", "FAILURE");
}
}
}