运行 Bitbucket 中的测试容器

Run testcontainers in Bitbucket

我正在添加 Testcontainers to my integration tests. Locally everything works fine. To let it run on my Bitbucket Pipelines, I created following (simplified) bitbucket-pipeline.yml:

image: maven:3.6.1

pipelines:
  default:
    - step:
      caches:
        - maven
      script:
        - export TESTCONTAINERS_RYUK_DISABLED=true
        - mvn -B verify
  branches:
    master:
     - step:
       caches:
         - maven
       services:
         - docker
       script:
         - ..
definitions:
  services:
    docker:
      memory: 2048

但是当管道启动 运行 并执行测试时,docker 服务似乎不存在:

Container startup failed
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=postgres:12.4, imagePullPolicy=DefaultPullPolicy())
Caused by: java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration

这个回答挺尴尬的。我忘了添加

services:
     - docker

部分到默认管道。因此,如日志记录所示,非 'master' 分支没有 docker 服务 运行。