Gitlab - CI和CD的定义阶段没有被纳入管道

时间:2018-01-24 23:52:03

标签: 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

在我进入管道的Gitlab中我期待看到3个阶段,即ver,init和deploy 然而,它只需要第一个阶段,我没有看到任何部署。

enter image description here

1 个答案:

答案 0 :(得分:3)

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

相关问题