Skip to content

Commit 9c390dd

Browse files
committed
refactored code as per review comments
- extracted default maven command code to separate method - changed variable names
1 parent d1dfb49 commit 9c390dd

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

vars/mavenCI.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def call(body) {
6363

6464
stage('Integration Testing') {
6565
mavenIntegrationTest {
66-
integrationTestCmd = config.integrationTestCmd
66+
cmd = config.integrationTestCmd
6767
environment = 'Test'
6868
failIfNoTests = false
6969
itestPattern = '*IT'

vars/mavenIntegrationTest.groovy

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/groovy
2+
23
import io.fabric8.Utils
34

45
def call(body) {
5-
def utils = new Utils()
66

7-
if (utils.isDisabledITests()) {
7+
if (new Utils().isDisabledITests()) {
88
echo "WARNING: Integration tests DISABLED for these pipelines!"
99
return
1010
}
@@ -15,10 +15,18 @@ def call(body) {
1515
body.delegate = config
1616
body()
1717

18+
def cmd = config.cmd ?: defaultTestCommand(config)
19+
sh cmd
20+
junitResults(body);
21+
}
22+
23+
def defaultTestCommand(config) {
24+
def utils = new Utils()
25+
1826
def envName = config.environment
1927
def kubeNS = "-Dfabric8.environment=${envName}"
2028

21-
if (envName && !config.integrationTestCmd) {
29+
if (envName) {
2230
try {
2331
def ns = utils.environmentNamespace(envName)
2432
if (ns) {
@@ -27,12 +35,12 @@ def call(body) {
2735
}
2836
} catch (e) {
2937
echo "ERROR: failed to find the environment namespace for ${envName} due to ${e}"
30-
e.printStackTrace()
3138
}
3239
}
3340

34-
def testCmd = config.integrationTestCmd ?: "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test -P openshift-it ${kubeNS} -Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests} org.apache.maven.plugins:maven-failsafe-plugin:verify"
35-
sh testCmd
36-
junitResults(body);
37-
41+
return "mvn \
42+
org.apache.maven.plugins:maven-failsafe-plugin:integration-test \
43+
org.apache.maven.plugins:maven-failsafe-plugin:verify \
44+
-P openshift-it ${kubeNS} \
45+
-Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests}"
3846
}

0 commit comments

Comments
 (0)