-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
58 lines (49 loc) · 1.45 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
node {
try {
checkout scm
updateGitlabCommitStatus name: 'jenkins', state: 'running'
docker.withRegistry('https://registry.docks.ercpe.de', 'docker-registry') {
docker.image('python:3.4').inside {
stage("Install dependencies") {
sh "make install_deps"
}
stage("Compile") {
sh "make compile compile_optimized"
}
stage("Run tests") {
sh "make test"
}
stage("Run coverage") {
sh "make coverage"
}
stage("Run pylint") {
sh "pylint -r n --msg-template='{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' > pylint-report.txt || true"
}
}
withCredentials([[
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'sonar',
usernameVariable: 'USERNAME',
passwordVariable: 'PASSWORD']]) {
docker.image('ercpe/sonar-scanner:latest').inside {
stage("Run sonar-scanner") {
sh "sonar-scanner -Dsonar.host.url=${SONAR_HOST} -Dsonar.login=${USERNAME} -Dsonar.password=${PASSWORD}"
}
}
}
}
updateGitlabCommitStatus name: 'jenkins', state: 'success'
} catch (e) {
currentBuild.result = "FAILED"
updateGitlabCommitStatus name: 'jenkins', state: 'failed'
notifyFailedBuild()
throw e
}
}
def notifyFailedBuild() {
emailext (
subject: "FAILED: ${env.JOB_NAME} [${env.BUILD_NUMBER}]",
body: """Job ${env.JOB_NAME} [${env.BUILD_NUMBER}] has FAILED: ${env.BUILD_URL}""",
recipientProviders: [[$class: 'CulpritsRecipientProvider']]
)
}