Skip to content

Define job to run after manual job completes successfully

Description

With a gitlab-ci.yml like this:

stages:
    - build
    - deploy

feature_build:
  stage: build
  tags: ["docker", "dind"]
  script: |
    docker run --rm=true -v `pwd`:/srv marmelab/bower bash -c "bower --allow-root --config.interactive=false install"
    bash ./docker-update.sh ${CI_COMMIT_REF_NAME}
  when: manual

feature_event_deploy:
  stage: deploy
  tags: ["autoscale-docker", "shell/sh", "unprivileged"]
  image: golang:alpine
  script:
    - go run ./marathon.go -mode feature -marathon-file ./marathon.json -tag ${CI_COMMIT_REF_NAME}
  when: manual

What I'd like to happen is when the feature_build stage completes successfully, for the feature_event_deploy to run. This is manual because we'll only want to deploy a feature build when we'd like to allow other people to test rather than just running locally.

Proposal

Not sure what the best way is, but the idea that came to mind first is after: feature_event_deploy or something like that, to allow people to define what should run if this completes. Like this:

stages:
    - build
    - deploy

feature_build:
  stage: build
  tags: ["docker", "dind"]
  script: |
    docker run --rm=true -v `pwd`:/srv marmelab/bower bash -c "bower --allow-root --config.interactive=false install"
    bash ./docker-update.sh ${CI_COMMIT_REF_NAME}
  when: manual
  after: feature_event_deploy

feature_event_deploy:
  stage: deploy
  tags: ["autoscale-docker", "shell/sh", "unprivileged"]
  image: golang:alpine
  script:
    - go run ./marathon.go -mode feature -marathon-file ./marathon.json -tag ${CI_COMMIT_REF_NAME}
  when: manual