forked from bloomberg/chef-bach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
27 lines (27 loc) · 1.22 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
node {
stage('Lint') {
checkout scm
withDockerContainer(image: 'chef/chefdk:1') {
sh script: 'chef exec rake style', returnStatus: true
echo 'BACH: rubocop preview'
sh 'tail rubocop.log'
echo 'BACH: foodcritic preview'
sh 'tail foodcritic.log'
}
warnings parserConfigurations: [
[pattern: 'rubocop.log', parserName: 'Rubocop'],
[pattern: 'foodcritic.log', parserName: 'Foodcritic']
]
if (currentBuild.rawBuild.project.name =~ /^PR-/) {
echo 'BACH: Comparing PR with master'
def masterBuild = currentBuild.rawBuild.project.parent.getItem('master').lastBuild.getAction(hudson.plugins.warnings.AggregatedWarningsResultAction).result
def prBuild = currentBuild.rawBuild.getAction(hudson.plugins.warnings.AggregatedWarningsResultAction).result
echo "This PR has ${prBuild.numberOfWarnings}"
echo "Master has ${masterBuild.numberOfWarnings}"
if (masterBuild.numberOfWarnings <= prBuild.numberOfWarnings) {
echo 'BACH: Master has less Lint Warnings'
currentBuild.result = 'FAILURE'
}
}
}
}