-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
69 lines (67 loc) · 2.3 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 any
stages {
stage('SCM'){
steps {
// Get some code from a GitHub repository
git 'https://github.com/Oskarin-koulutehtavat/DevOpsExample.git'
}
}
stage('Maven Build') {
steps {
// Run Maven on a Unix agent.
withSonarQubeEnv(installationName: 'sonar', credentialsId: 'SQT_WSL') {
withMaven(maven: 'Maven 3.9.6') {
sh 'mvn -Dskip.tests clean package sonar:sonar'
}
}
// To run Maven on a Windows agent, use bat instead of sh
}
post {
// If Maven was able to compile archive the jar file.
success {
archiveArtifacts 'target/*.jar'
}
}
}
stage('Maven Test') {
steps {
// Run Maven tests.
withMaven(maven: 'Maven 3.9.6') {
sh 'mvn test'
}
}
post {
// If Maven was able to run the tests, even if some of the test
// failed, record the test results.
always {
junit 'target/surefire-reports/*.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('Docker Build') {
steps {
// Build docker image tagged example/matrix:latest using
// the current directory (.) as a build context
sh 'docker build -t example/matrix:latest .'
}
post {
// If Docker was able to build an image.
success {
sh 'mkdir -p target/docker'
sh 'docker save -o target/docker/image.tar example/matrix:latest'
archiveArtifacts 'target/docker/image.tar'
}
}
}
}
}