Gitlab - 未在管道中采用 CI 和 CD 的定义阶段

Ben*_*min 3 gitlab gitlab-ci gitlab-ci-runner

我有一个 .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
Run Code Online (Sandbox Code Playgroud)

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

在此处输入图片说明

Ste*_*tel 6

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