Carlos Rojas
Carlos Rojas

Reputation: 354

Gitlab CI/CD deploy a stage just once

Is there a way to execute a stage just once, only the first time that the pipeline is executed

For example, if I have this stages

I wanna execute N pipelines but without execute 'tag_version' the next times, just execute it at the first time

Upvotes: 0

Views: 42

Answers (2)

Carlos Rojas
Carlos Rojas

Reputation: 354

I solved using the following rule, catching the push event and matching with my tag that I wanna tag. In this way my stage is executed once

.mycondition: &mycondition
  rules:
    - if: '$CI_COMMIT_TAG =~ /^release-v\d+$/ && $CI_PIPELINE_SOURCE == "push"'
      when: always

Upvotes: 1

Iron Bishop
Iron Bishop

Reputation: 1988

You can use rules: changes, maybe combined with when: manual, so that the tag is executed only when a specific file is changed (say, the Dockerfile).

See https://docs.gitlab.com/ee/ci/yaml/#ruleschanges

Upvotes: 1

Related Questions