Gitlab - CI 和 CD 的定义阶段未进入管道

Gitlab - Defined stages for CI and CD are not being taken in the pipeline

我有一个 .gitlab-ci.yml 文件如下:

image: node:6.10.3

stages:
  - ver
  - init
  - deploy

ver:
  stage: ver
  script:
    - node --version
    - whoami
init:
  stage: init
  script:
    - npm cache clean
    - rm -rf node-modules
    - npm install

deploy_staging:
  stage: deploy
  before_script:
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - mkdir -p ~/.ssh
  - eval $(ssh-agent -s)
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  script:
    - ssh-add <(echo "$STAGING_PRIVATE_KEY" | base64 --decode)
    - git pull
    - echo "deployed to staging server"
  environment:
    name: staging
    url: MY SERVER

  only:
    - master

在 Gitlab 中,当我进入管道时 我希望看到 3 个阶段,即 ver、init 和 deploy但是,它只需要第一个阶段,我没有看到任何部署。

因此,在部署作业中使用 only: master 语句,您可以将其排除在其他分支中。 Gitlab 不会在管道中显示它,因为它从未用于非主分支。