推标签后的Gitlab

时间:2018-08-09 06:07:06

标签: gitlab-ci gitlab-ci-runner

是否可以通过以下方式配置项目的gitlab-yml:在将标签推出后,它可以运行多个命令?如果是这样,您如何得到它?我还想定义要在这几个命令中使用的变量。

我的gitlab-ci看起来像:

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - composer install --no-ansi
    - vendor/bin/phar-composer build
  artifacts:
    paths:
      - example.phar
  tags:
    - php:7.0

deploy:
  stage: deploy
  only:
    - tags
  dependencies:
    - build
  script:
    - cp example.phar /opt/example/
  tags:
    - php:7.0

这与运行example.phar bin/console command1 $VARIABLE1 $VARIABLE2 $VARIABLE3 $VARIABLE4有关。

请帮助我,因为我对这些问题并不完全熟悉。

1 个答案:

答案 0 :(得分:1)

使用only参数推送一个标签时,您可以触发作业:

build:
  stage: build
  image: alpine:3.6
  script:
  - echo "A tag has been pushed!"
  only:
  - tags