Gradle Gitlab CI并行运行不同的测试

Gradle Gitlab CI并行运行不同的测试,gradle,gitlab,gitlab-ci,Gradle,Gitlab,Gitlab Ci,我有一个项目需要在不同的环境(Postgres、Oracle等)中运行集成测试 为此,我创建了不同的任务,根据db设置不同的环境变量,如: task postgresqlIntegrationTest(type: Test, group: "Verification", description: "Runs integration tests on postgresql.") { dependsOn compileTestJava mustRunAfter test e

我有一个项目需要在不同的环境(Postgres、Oracle等)中运行集成测试

为此,我创建了不同的任务,根据db设置不同的环境变量,如:

task postgresqlIntegrationTest(type: Test, group: "Verification", description: "Runs integration tests on postgresql.") {
    dependsOn compileTestJava
    mustRunAfter test

    environment "env", "postgresql"

      useJUnitPlatform {
        filter {
            includeTestsMatching "*IT"
        }
    }
}
它可以毫无问题地工作

现在,我想并行运行我当前在.gitlab-ci.yml文件中配置的任务,如下所示:

image: docker

variables:
  BUILD_ID: "job# $CI_JOB_ID"
  GIT_COMMIT: $CI_COMMIT_SHA
  GIT_BRANCH: $CI_COMMIT_REF_NAME

stages:
  - test

test:unit:
  stage: test
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ls -la
    - git status
    - git config --global user.name "Git Lab"
    - ./gradlew test --stacktrace --info

test:h2:
  stage: test
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ls -la
    - git status
    - git config --global user.name "Git Lab"
    - ./gradlew h2IntegrationTest--stacktrace --info

test:postgres:
  stage: test
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ls -la
    - git status
    - git config --global user.name "Git Lab"
    - ./gradlew postgresqlIntegrationTest --stacktrace --info

test:oracle:
  stage: test
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ls -la
    - git status
    - git config --global user.name "Git Lab"
    - ./gradlew oracleIntegrationTest --stacktrace --info
然而,这会导致为每个并行任务运行“TestClass”、“compileTestJava”、“classes”等步骤,这似乎是一种浪费。有没有什么方法可以让我先执行这些基本任务,然后在“测试”阶段使用它们

我是否仍然需要运行
gradlew build
,或者在运行所有测试时,我的任务是否相同

使集成测试并行的正确方法是什么