简体   繁体   中英

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

  • build
  • tag_version
  • test
  • deploy

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM