we are using Gradle. We are using Jenkins for our CI-CD. The Jenkins stages in our project is Checkout
, Build and unit test
, Sonar
, Docker
, Approve deployment
, Dev deployment
and Integration test
.
How can I run only unit tests during Build and unit test
step in Jenkins and run only Integration test
after Dev Deployment Jenkins?
I have attached a screenshot wherein I have included Integration test and excluded Unit tests in build.gradle
file, but it's not the correct way.
Below is my Jenkins Groovy file:
Map buildOptions(Map optionParams) {
return [
javaVersion: '11.0'
] optionParams
}
void call(Map optionParams = [:]) {
buildIfNotRelease(buildOptions(optionParams))
}
boolean buildIfNotRelease(Map options = [:]) {
def buildCommand = options.buildSystem == 'maven' ? 'mvn clean package' : './gradlew clean build'
return sh(script: "export JAVA_VERSION=${options.javaVersion};. /etc/profile.d/jenkins.sh;${buildCommand}"
// returnStatus: true
) == 0
}
CodePudding user response:
Separate your integration test into different sourceSet
using the jvm-test-suite-plugin.
This way you have a dedicated tasks for test
and integrationTest
and you don't have to deal with include
/exclude
stuff.
If you want to have some common test code, then use the java-test-fixtures-plugin.