首页 > 解决方案 > GITLAB CI 管道未触发

问题描述

我已经为 GitLab CI/CD 编写了这个 yml 文件。有一个已配置并正在运行的共享运行器。我是第一次这样做,不知道哪里出错了。我在 repo 上的 angular js 项目有一个 gulp 构建文件,可以在本地机器上完美运行。这段代码只需要在我的跑步者所在的虚拟机上触发它。提交时,管道不显示任何作业。让我知道需要纠正的地方!

image: docker:latest

cache:
  paths:
    - node_modules/

deploy_stage:
  stage: build
  only:
    - master
  environment: stage
  script:
  - rmdir -rf "build"
  - mkdir "build"
  - cd "build"
  - git init
  - git clone "my url"
  - cd "path of cloned repository"
  - gulp build

标签: continuous-integrationgitlab

解决方案


你要投身哪个分支?master您的管道配置为仅在分支上提交时运行。

...
  only:
    - master
...

如果您还想为其他分支触发作业,请从.gitlab-ci.yml文件中删除此限制。

不要忘记Enable shared Runners(默认情况下它们可能未启用),可以在 GitLab 项目页面下的Settings -> CI/CD -> Runners.

更新:您的管道触发器是否曾经为您的项目工作过?

如果没有,那么我会尝试配置简单的管道来测试触发器是否正常工作:

test_simple_job:
  script:
    - echo I should execute for any pipeline trigger.

推荐阅读