Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a .gitlab-ci.yml file as below:

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

In Gitlab when I go to pipeline I am expecting to see 3 stages which are ver, init, and deploy. However, It only takes the first to stages and I don't see anything for deploy.

enter image description here

like image 521
Benjamin Avatar asked Mar 07 '23 02:03

Benjamin


1 Answers

So using the only: master statement in the deploy job you exclude that from being touched at all in other branches. Gitlab doesn't show it in the pipeline as it was never used for non-master branches.

like image 61
Stefan van Gastel Avatar answered Mar 09 '23 17:03

Stefan van Gastel