0

I have been assigned to a project which uses git submodules. I did a small change in the markdown of the README.md and received the following error:

Running on staging.example.com...
Fetching changes...
HEAD is now at 2414dbe test change
From https://gitlab.example.com/external/project-example
   2432dbe..b64b2d0  develop    -> origin/develop
Checking out b452d91 as develop...
$ docker rm -f $CONTAINER_NAME-db
Error response from daemon: No such container: project-example-db
ERROR: Build failed: exit status 1

When I check the file named: .gitlab-ci.yml I see this code:

# ADD   

install:clean:
    stage: prepare
    script:
        - docker rm -f $CONTAINER_NAME-db
        - docker rm -f $CONTAINER_NAME
        - docker rmi $IMAGE_NAME
    allow_failure: true
    tags:
      - staging

# BUILD

prepare:build:
    stage: prepare
    script:
        - git submodule init
        - git submodule update --recursive
        - docker-compose build --no-cache --pull
    tags:
      - staging

I'm not sure if my error is due to something missing with the submodules, my .gitmodules file looks like this:

[submodule "frontend"]
    path = frontend
    url = git@gitlab.example.com:external/project-example-frontend.git
    branch = v3.1

I have the 2 repos (project-example & project-example-frontend) inside a directory. What am I missing?

CommonSenseCode
  • 23,522
  • 33
  • 131
  • 186

1 Answers1

1

You are trying to remove the containers project-example-db and project-example (using docker rm) while project-example-db doesn't exist. In such case the command returns a non-zero exit status and thus the whole job fails. From the information you provided it's not completely clear how the containers are started. You can:

  1. Check that the containers exist and attempt to remove them only if they do.
  2. If the containers are started with docker-compose (in the prepare:build job), you can remove them with docker-compose down instead which would do it gracefully and would not fail if the containers are not running.
Community
  • 1
  • 1
tmt
  • 7,611
  • 4
  • 32
  • 46