'Cloud Build access database started in container

want to migrate from bitbucket to cloud build. Bitbucket has so called services, where I can start postgres database in parallel to my build and use this service in my gradle build as a test database. So, I have tried to start postgres container in cloud build at the first step. But I do not know how in the next step which is buildpack, which runs gradle, which builds spring and which needs that database shall I provide the URL to connect to that database which I have started in first step in container. Example would be something like:

steps:
  - name: gcr.io/cloud-builders/docker
    id: start_postgres
    args: ["run", "-dt", "--name-postgres", "--network=cloudbuild", ... , "postgres"]
  - name: gcr.io/k8s-skaffold/pack
    id: buildpack
    entrypoint: pack
    args:
      - 'build'
      - .....
      - 'BP_GRADLE_BUILD_ARGUMENT=....... -PINT_TEST_DB_URL=<URL>

Would appreciate any ideas. Please do not propose testcontainers - don't work in cloud build. Many thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source