blob: 10d8ece3e18525f02165476cbf3bcc309c335b17 [file] [log] [blame]
Jakub Josefd75c1d52017-03-15 18:06:03 +01001/**
2* Groovy code testing pipeline
3* CREDENTIALS_ID - gerrit credentials id
4* GRADLE_IMAGE - gradle image name
5* GRADLE_CMD - command(s) for gradle
6*
7**/
8
9gerrit = new com.mirantis.mk.Gerrit()
10common = new com.mirantis.mk.Common()
11
12node("docker"){
13 try {
14 stage ('Checkout source code'){
15 gerrit.gerritPatchsetCheckout ([
16 credentialsId : CREDENTIALS_ID,
17 withWipeOut : true
18 ])
19 }
20 stage ('Run Codenarc tests'){
21 def workspace = common.getWorkspace()
22 def gradle_report = sh (script: "docker run --rm -v ${workspace}:/usr/bin/app:rw ${GRADLE_IMAGE} ${GRADLE_CMD}",
23 returnStdout: true).trim()
24 // Compilation failure doesn't fail the build
25 // Check gradle output explicitly
26 common.infoMsg(gradle_report)
27 if ( gradle_report =~ /Compilation failed/ ) {
28 throw new Exception("COMPILATION FAILED!")
29 }
30 }
31
32 } catch (Throwable e) {
33 currentBuild.result = 'FAILURE'
Jakub Josef97e09572017-03-22 13:59:02 +010034 try{
35 def errLog = readFile('build/reports/codenarc/main.txt')
36 if(errLog){
37 common.errorMsg("Error log: ${errLog}")
38 }
39 }catch(ex){}
Jakub Josefd75c1d52017-03-15 18:06:03 +010040 throw e
41 } finally {
42 // send notification
43 common.sendNotification(currentBuild.result, "" ,["slack"])
44 }
45}