简体   繁体   中英

Gitlab pipeline doesn't activate with .gitlab-ci.yml file in repo root

I am using GitLab for my CI/CD. I have a Firebase application where I am trying to deploy the functions. However, the pipeline does not activate/get created, even with the .gitlab-ci.yml file. I have enabled shared runners, my code is in my dev branch which I am referring to in the ci file.

My folder structure looks like (with .gitlab-ci.yml file at the root of the repo):

- .gitlab-ci.yml
- project
  - functions
    - ...
  - src
    - ...

My gitlab-ci.yml file:

image: node:12.13.0-alpine

variables:
  ENV: "dev"

before_script:
  - npm i -g firebase-tools

stages:
  - build
  - deploy

DeployFunctions:
  stage: deploy
  script:
    - cd project/functions
    - npm install
    - cd ..
    - firebase deploy --only functions --token $TBT_DEV_FIREBASE_CI
  only:
    refs:
      - dev
    changes:
      - functions/**/*

When I lint the file using the GitLab CI Lint, and I lint it without selecting the option "Simulate a pipeline created for the default branch", the syntax seems to be correct. However, when I select that option, I get the following error:

No stages / jobs for this pipeline.

When I add the Builder job ie the following block, everything works fine:

...

stages:
  - build
  - deploy

Builder:
  stage: build
  script:
    - echo "Commencing build"

DeployFunctions:
  stage: deploy
  script:

...

This leads me to believe that I'm not correctly defining the DeployFunctions job. Can anyone see what is wrong with it?

Any help is much appreciated! Thanks in advance!

The fact that no pipeline gets created makes it seem that it's an issue with the only: refs tag. I linted your file, the syntax is correct.

Is your CI file included in your dev branch? As far as I'm concerned it should work as long as the .gitlab-ci.yml is tracked on the dev branch and you push to that branch. Did you do all of that?

I was able to get my pipelines to create after removing some configuration from my .gitlab-ci.yml file. In the end I removed the entire only block. Somehow, the configuration under this block was wrong, including the changes block under only , even though the same configuration can be seen in many .gitlab-ci.yml examples.

image: node:12.13.0-alpine

before_script:
  - npm i -g firebase-tools

stages:
  - deploy

DeployFunctions:
  stage: deploy
  script:
    - cd project/functions
    - npm install
    - cd ..
    - firebase deploy --only functions --token $DEV_FIREBASE_CI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM