Skip to content

Commit 4a1e003

Browse files
committed
mavenIntegrationTest: allow overriding mvn commands
This patch allows the to over maven command in order to allow integration tests to pass specific maven flags. Related to: fabric8io#412
1 parent 92fc97e commit 4a1e003

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

ReadMe.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ NOTE: if `cmd` is set, `goal`, `profile`, `skipTests` will have no effect.
212212
itestPattern = '*KT'
213213
}
214214
```
215+
- pass `cmd` parameter to override the `mvn` command to execute in integration test
216+
```groovy
217+
mavenIntegrationTest {
218+
cmd = 'mvn -P openshift-it org.apache.maven.plugins:maven-failsafe-plugin:verify'
219+
}
220+
```
215221
#### Merge and Wait for Pull Request
216222

217223
- adds a [merge] comment to a github pull request
@@ -248,7 +254,7 @@ NOTE: if `cmd` is set, `goal`, `profile`, `skipTests` will have no effect.
248254
}
249255
```
250256
#### Update Maven Property Version
251-
During a release involving multiple java projects we often need to update downstream maven poms with new versions of a dependency. In a release pipeline we want to automate this, set up a pull request and let CI run to make sure there's no conflicts.
257+
During a release involving multiple java projects we often need to update downstream maven poms with new versions of a dependency. In a release pipeline we want to automate this, set up a pull request and let CI run to make sure there's no conflicts.
252258

253259
- performs a search and replace in the maven pom
254260
- finds the latest version available in maven central (repo is configurable)
@@ -274,7 +280,7 @@ Automating this has saved us a lot of time during the release pipeline
274280
}
275281
```
276282
#### Wait Until Artifact Synced With Maven Central
277-
When working with open source java projects we need to stage artifacts with OSS Sonatype in order to promote them into maven central. This can take 10-30 mins depending on the size of the artifacts being synced.
283+
When working with open source java projects we need to stage artifacts with OSS Sonatype in order to promote them into maven central. This can take 10-30 mins depending on the size of the artifacts being synced.
278284

279285
A useful thing is to be notified in chat when artifacts are available in maven central as blocking the pipeine until we're sure the promote has worked.
280286

@@ -324,7 +330,7 @@ When a project is staged an array is returned and passed around functions furthe
324330
}
325331
```
326332

327-
One other important note is on the fabric8 project we don't use the maven release plugin or update to next SNAPSHOT versions as it causes unwanted noise and commits to our many github repos. Instead we use a fixed development `x.x-SNAPSHOT` version so we can easily work in development on multiple projects that have maven dependencies with each other.
333+
One other important note is on the fabric8 project we don't use the maven release plugin or update to next SNAPSHOT versions as it causes unwanted noise and commits to our many github repos. Instead we use a fixed development `x.x-SNAPSHOT` version so we can easily work in development on multiple projects that have maven dependencies with each other.
328334

329335
Now that we don't store the next release version in the poms we need to figure it out during the release. Rather than store the version number in the repo which involves a commit and not too CD friendly (i.e. would trigger another release just for the version update) we use the `git tag`. From this we can get the previous release version, increment it and push it back without triggering another release. This seems a bit strange but it has been holding up and has significantly reduced unwanted SCM commits related to maven releases.
330336

@@ -389,8 +395,8 @@ Now that we don't store the next release version in the poms we need to figure i
389395
```
390396
#### Git Tag
391397

392-
- tags the current git repo with the provided version
393-
- pushes the tag to the remote repository
398+
- tags the current git repo with the provided version
399+
- pushes the tag to the remote repository
394400

395401
```groovy
396402
gitTag {
@@ -415,9 +421,9 @@ __NOTE__ in order for images to be found by the remote OpenShift instance it mus
415421

416422
#### Deploy Remote Kubernetes
417423

418-
Deploys the staged fabric8 release to a remote Kubernetes cluster
424+
Deploys the staged fabric8 release to a remote Kubernetes cluster
419425

420-
__NOTE__ in order for images to be found by the remote OpenShift instance it must be able to pull images from the staging docker registry. Noting private networks and insecure-registry flags.
426+
__NOTE__ in order for images to be found by the remote OpenShift instance it must be able to pull images from the staging docker registry. Noting private networks and insecure-registry flags.
421427

422428
```groovy
423429
node {
@@ -587,7 +593,7 @@ For this case you can combine add the docker template and the maven template tog
587593
node('maven-and-docker') {
588594
container(name: 'maven') {
589595
sh 'mvn clean package fabric8:build fabric8:push'
590-
}
596+
}
591597
}
592598
}
593599
}
@@ -598,7 +604,7 @@ The above is equivalent to:
598604
mavenNode(label: 'maven-and-docker') {
599605
container(name: 'maven') {
600606
sh 'mvn clean package fabric8:build fabric8:push'
601-
}
607+
}
602608
}
603609
}
604610

@@ -613,7 +619,7 @@ In the example above we can add release capabilities too, by adding the releaseT
613619
mvn release:clean release:prepare
614620
mvn clean release:perform
615621
"""
616-
}
622+
}
617623
}
618624
}
619625
}

vars/mavenIntegrationTest.groovy

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def call(body) {
1111
def utils = new Utils()
1212
def envName = config.environment
1313
def kubeNS = "-Dfabric8.environment=${envName}"
14+
def cmd = cmd ?: "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test ${kubeNS} -P openshift-it -Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests} org.apache.maven.plugins:maven-failsafe-plugin:verify"
15+
1416
if (envName) {
1517
// lets try find the actual kubernetes namespace
1618
try {
@@ -29,8 +31,7 @@ def call(body) {
2931
echo "WARNING: Integration tests are current DISABLED for these pipelines!"
3032

3133
} else {
32-
sh "mvn org.apache.maven.plugins:maven-failsafe-plugin:integration-test ${kubeNS} -P openshift-it -Dit.test=${config.itestPattern} -DfailIfNoTests=${config.failIfNoTests} org.apache.maven.plugins:maven-failsafe-plugin:verify"
33-
34+
sh cmd
3435
junitResults(body);
3536
}
3637
}

0 commit comments

Comments
 (0)