-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
126 lines (115 loc) · 4.35 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!groovy
// Copyright (c) 2020-2021, AT&T Intellectual Property. All rights reserved.
// SPDX-License-Identifier: GPL-2.0-only
// Pull Request builds might fail due to missing diffs: https://issues.jenkins-ci.org/browse/JENKINS-45997
// Pull Request builds relationship to their targets branch: https://issues.jenkins-ci.org/browse/JENKINS-37491
@NonCPS
def cancelPreviousBuilds() {
def jobName = env.JOB_NAME
def buildNumber = env.BUILD_NUMBER.toInteger()
// Get job name
def currentJob = Jenkins.instance.getItemByFullName(jobName)
// Iterating over the builds for specific job
for (def build : currentJob.builds) {
// If there is a build that is currently running and it's not current build
if (build.isBuilding() && build.number.toInteger() != buildNumber) {
// Than stopping it
build.doStop()
}
}
}
pipeline {
agent {
dockerfile true
}
options {
timeout(time: 180, unit: 'MINUTES') // Hopefully maximum even when Valgrind is included!
quietPeriod(30) // Wait in case there are more SCM pushes/PR merges coming
ansiColor('xterm')
timestamps()
}
stages {
// A work around, until this feature is implemented: https://issues.jenkins-ci.org/browse/JENKINS-47503
stage('Cancel older builds') { steps { script {
cancelPreviousBuilds()
}}}
// Don't run package in parallel as I think the files generated by other stages breaks dpkg-buildpackage.
stage('package') {
steps {
sh "invoke package"
}
}
// Run lintian before pycache files are generated.
stage('lintian') {
steps {
sh "invoke lintian"
}
}
stage(' ') {
parallel {
stage('flake8') {
steps {
sh "invoke flake8 --commits upstream/${env.CHANGE_TARGET}...origin/${env.BRANCH_NAME}"
}
}
stage('mypy') {
steps {
sh "invoke mypy --commits upstream/${env.CHANGE_TARGET}...origin/${env.BRANCH_NAME}"
}
}
stage(' ') {
stages {
stage('pytest') {
steps {
sh "invoke pytest"
}
}
stage('coverage') {
steps {
sh "invoke coverage"
}
post {
always {
archiveArtifacts artifacts: 'htmlcov/', fingerprint: true
}
}
}
}
}
stage('gitlint') {
steps {
sh "invoke gitlint --commits upstream/${env.CHANGE_TARGET}...origin/${env.BRANCH_NAME}"
}
}
stage('licence') {
steps {
sh "invoke licence --commits upstream/${env.CHANGE_TARGET}...origin/${env.BRANCH_NAME}"
}
}
stage('whitespace') {
steps {
sh "invoke whitespace --commits upstream/${env.CHANGE_TARGET}...origin/${env.BRANCH_NAME}"
}
}
stage('perlcritic') {
steps {
sh script: "perlcritic --quiet --severity 5 . 2>&1 | tee perlcritic.txt", returnStatus: true
}
post {
always {
discoverGitReferenceBuild()
recordIssues tool: perlCritic(pattern: 'perlcritic.txt'),
enabledForFailure: true,
qualityGates: [[type: 'TOTAL', threshold: 10, unstable: true]]
}
}
}
} // parallel
} // Stage ' '
} // stages
post {
always {
deleteDir()
}
}
}