-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUnitTesting.groovy
76 lines (71 loc) · 2.55 KB
/
UnitTesting.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
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
#!groovy
/**
* Jenkinsfile for Jenkins2 Pipeline
* author: [email protected]
*/
package main.com.rocc.stages.impl
import groovy.lang.Closure;
import java.nio.file.*
import groovy.util.AntBuilder.*
/**
* Method used to execute junit
* @param workspace
*/
def execUnitTestCases( def wspace, def antpath) {
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'
echo "Ant file path for unit test execution: "+build_file
def proc = sh(returnStdout: true, script: "${antpath}/bin/ant -f $build_file -DdisableUnitTest=false build")
println proc
/*def b = new StringBuffer()
proc.consumeProcessErrorStream(b)
println proc.text
println b.toString()*/
}
catch (Exception groovyEx) {
println groovyEx.getMessage()
println groovyEx.getCause()
throw groovyEx
}
}
/**
* Function: Method used to publish sonar report
* @param wspace
* @return
*/
def publishReport( def wspace) {
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')
junit allowEmptyResults: true, testResults: wspace+'/'+"${app_path}"+'/reports/junit/xml/*.xml'
//publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: wspace+'/WebCommerce/rocc/reports/html', reportFiles: 'index.html', reportName: 'HTML Report'])
//publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: '/u02/app/ci/jenkins/jobs/Release1.2-track-WebCommerce-PollSCM/workspace/kairos/reports/html', reportFiles: 'index.html', reportName: 'Report'])
}
catch (Exception groovyEx) {
println groovyEx.getMessage()
println groovyEx.getCause()
throw groovyEx
}
}