blob: 66e0393aeaa871e58997e997913d6dcf55bdda77 [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()
Jakub Josef1ee1e4a2017-03-23 12:36:25 +010022 def jenkinsUID = common.getJenkinsUid()
23 def jenkinsGID = common.getJenkinsGid()
24 def gradle_report = sh (script: "docker run --rm -v ${workspace}:/usr/bin/app:rw -u ${jenkinsUID}:${jenkinsGID} ${GRADLE_IMAGE} ${GRADLE_CMD}", returnStdout: true).trim()
Jakub Josefd75c1d52017-03-15 18:06:03 +010025 // Compilation failure doesn't fail the build
26 // Check gradle output explicitly
27 common.infoMsg(gradle_report)
28 if ( gradle_report =~ /Compilation failed/ ) {
29 throw new Exception("COMPILATION FAILED!")
30 }
31 }
32
33 } catch (Throwable e) {
34 currentBuild.result = 'FAILURE'
Jakub Josef97e09572017-03-22 13:59:02 +010035 try{
36 def errLog = readFile('build/reports/codenarc/main.txt')
37 if(errLog){
38 common.errorMsg("Error log: ${errLog}")
39 }
40 }catch(ex){}
Jakub Josefd75c1d52017-03-15 18:06:03 +010041 throw e
42 } finally {
43 // send notification
44 common.sendNotification(currentBuild.result, "" ,["slack"])
45 }
46}