-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathJenkinsfile
84 lines (81 loc) · 3.03 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
pipeline {
parameters {
string(name: 'IMAGE_VERSION', defaultValue: "1.8.0")
string(name: 'DOCKER_REGISTRY', defaultValue: DEFAULT_DOCKER_REGISTRY)
string(name: 'EMAIL_TO', defaultValue: "")
}
environment {
registryCredentialsID = 'csi_w3_user'
}
options {
ansiColor('xterm')
}
agent {
label "${env.AGENT_LABEL}"
}
stages {
stage ('CSI-controller: static code analysis') {
steps {
sh './scripts/run_static_code_analysis.sh'
}
}
stage ('CSI-controller: Unit testing + coverage') {
steps {
sh 'mkdir -p build/reports && chmod 777 build/reports'
sh './scripts/run_unitests.sh `pwd`/build/reports'
}
}
stage ('CSI-node: go local tests') {
steps {
sh 'mkdir -p build/reports && chmod 777 build/reports'
sh 'make test-xunit-in-container'
}
}
stage ('k8s yamls validation') {
steps {
sh './scripts/run_yamlcheck.sh'
}
}
stage ('CSI-controller & node: Build and push images') {
steps {
script {
registryUrl = "https://${DOCKER_REGISTRY}"
docker.withRegistry(registryUrl, registryCredentialsID) {
sh './scripts/ci/build_push_images.sh build/reports/images_url'
}
}
}
}
}
post {
always {
script {
manager.addShortText("${env.GIT_BRANCH}")
}
sh 'ls -la build/reports/'
junit 'build/reports/*.xml'
// cobertura coberturaReportFile: 'build/reports/*.xml' ## TODO: CSI-103 need to run cobertura but it has an issue "No such DSL method"
archiveArtifacts 'build/reports/images_url'
}
failure {
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
to: "${env.EMAIL_TO}",
subject: 'Build failed in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
}
unstable {
emailext body: 'Check console output at $BUILD_URL to view the results. \n\n ${CHANGES} \n\n -------------------------------------------------- \n${BUILD_LOG, maxLines=100, escapeHtml=false}',
to: "${env.EMAIL_TO}",
subject: 'Unstable build in Jenkins: $PROJECT_NAME - #$BUILD_NUMBER'
}
changed {
emailext body: 'Check console output at $BUILD_URL to view the results.',
to: "${env.EMAIL_TO}",
subject: 'Jenkins build is back to normal: $PROJECT_NAME - #$BUILD_NUMBER'
}
cleanup {
script {
sh '[ -d build/reports ] && rm -rf build/reports'
}
}
}
}