Sequential startup of pipelines

If i have .gitlab-ci.yml like this

stages:
  - build
  - deploy

build_app:
  stage: build
  script:
    - build-and-push-to-dockerhub.sh

deploy:
  stage: deploy
  script:
    - push-from-dockerhub-to-deis.sh

When I pushed 2 commits in the same time, I can have a bad situation:

  • started commit A build_app task
  • started commit B build_app task (he overwrites previous image on a dockerhub)
  • started commit A deploy task, and checksums of docker images are different, pipeline failed

As solution I want to say to gitlab that only one pipeline can be runned in the same time. As I know, now gitlab don’t gives me a posibility to do this.

A part of a problem can be solved with gitlab runner with throughput value 1, but I can’t use it for all my cases.

How can I solve this problem? Maybe, gitlab team can implement a posibility to set a sequential startup of pipelines?

Thanks