Mark a job as skipped via exit code

Note: See https://gitlab.com/gitlab-org/gitlab-ce/issues/37397 and https://gitlab.com/gitlab-org/gitlab-ce/issues/19232 for similar issues that are covering this request.

I understand the existing Skipping Builds functionality, but I'd like to conditionally skip a build based on an arbitrary condition in my build script. For example, maybe you don't want to deploy if the branch is not master, so you do something like:

  script:
    - |
      if [ "$CI_BUILD_REF_NAME" != "master" ]; then
        echo "Skipping deploy for non-master branch $CI_BUILD_REF_NAME"
        exit 0
      fi

This is fine, but it's not very semantic: the CI view shows all green, when in reality it should indicate that the build step was skipped (yellow?).

Edited Oct 29, 2018 by Fabio Busatto
Assignee Loading
Time tracking Loading