Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将外部存储库与GitLab runner一起使用?_Gitlab - Fatal编程技术网

如何将外部存储库与GitLab runner一起使用?

如何将外部存储库与GitLab runner一起使用?,gitlab,Gitlab,我的GitLab中有两个项目。 一个是后端(Golang) 另一个是前端(Vue.js) 我想在更新bakend代码时触发后端和前端的CI。 因此,我在后端项目中有一个.gitlab ci.yml,如下所示 stages: - backendCI - frontendCI backendCI: image: golang:latest stage: backendCI script: - make all frontendCI: image: node:lat

我的GitLab中有两个项目。 一个是后端(Golang) 另一个是前端(Vue.js)

我想在更新bakend代码时触发后端和前端的CI。 因此,我在后端项目中有一个
.gitlab ci.yml
,如下所示

stages:
  - backendCI
  - frontendCI

backendCI:
  image: golang:latest
  stage: backendCI
  script:
    - make all

frontendCI:
  image: node:latest
  stage: frontendCI
  script:
    - npm install
    - npm run build 

  dependencies:
    - repository: sw/frontend
      on: develop

但有一个错误:

错误:作业:前端依赖项应为字符串数组


我不知道如何在后端runner中使用前端存储库。

该错误意味着yaml文件无效。您误解了
依赖项的用法,它只引用以前的作业来从中获取工件

如果我很了解您的案例,您有两个独立的存储库,因此您可以有两个独立的
.gitlab ci.yml
,并且您可以使用以下命令轻松触发另一个管道:

curl--request POST--header“PRIVATE-TOKEN:”\
"https://gitlab.example.com/api/v4/projects/ID/pipeline?ref=develop"
在引用前端项目的后端的
.gitlab ci.yml
中进行调用(将url中的ID替换为前端项目的ID)

如果您是Gitlab Premium(版本>=11.8),则有一个本机程序可以触发跨项目管道

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ 
"https://gitlab.example.com/api/v4/projects/ID/pipeline?ref=develop"