-
Notifications
You must be signed in to change notification settings - Fork 7
/
SonarAnalysis.groovy
44 lines (42 loc) · 1.54 KB
/
SonarAnalysis.groovy
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
#!groovy
/**
* Jenkins file for ROCC Pipeline
* Author: [email protected]
*/
/**
* Import the package for using the class functions
*/
package main.com.rocc.stages.impl
import main.com.rocc.stages.impl.ATGAntBuild
/**
* Function: File used for sonar analysis
* @Params: workspace,pom and branch name mandatory
*/
void execSonarAnalysis( def wspace, def ant_path, def java_path) {
try {
echo "chopping the string"
def str = wspace[-1..-1]
if (str.isNumber()) {
ws = wspace[0..-3]
file_path = ws+"@libs/DevOps/resources/config/prod_dev_weblogic.properties"
} else {
file_path = wspace+"@libs/DevOps/resources/config/prod_dev_weblogic.properties"
}
Properties props = new Properties()
File propsFile = new File("$file_path")
props.load(propsFile.newDataInputStream())
def app_path = props.getProperty('module.workspace')
def build_file = wspace+'/'+"${app_path}"+'/build_scripts/build_weblogic.xml'
def res = sh(returnStdout: true, script: "export JAVA_HOME=${java_path}; ${ant_path}/bin/ant -f $build_file sonar -DdisableSonar=false -Dsonar.language=java -Dsonar.issuesReport.html.enable=true -Dsonar.issuesReport.console.enable=true -Dsonar.issuesReport.lightModeOnly=true -Dsonar.scm.disabled=true")
println res
/*def proc = "".execute()
def b = new StringBuffer()
proc.consumeProcessErrorStream(b)
echo proc.text
echo b.toString()*/
}
catch (Exception groovyEx) {
println "Error while sonar analysis :"+groovyEx.getMessage()
println groovyEx.getCause()
}
}