0

我想自动化项目的构建和部署。在这方面,我想使用 Gitlab API 来重试 Gitlab Pipeline 中的特定作业。

我进行的 API 调用如下:

curl --request POST --header "PRIVATE-TOKEN: xxx" " https://gitlab.example.com/api/v4/projects/1/jobs/1/retry "

否则我的作业可以手动触发,我的 gitlab-ci.yml 文件如下所示:

execute_octoDeploy:
  tags:
    - windows
  stage: build
  when: manual
  script:
    - .\BuildScripts\octodeploy.ps1

我收到 403 错误,根据https://docs.gitlab.com/ee/api/README.html表示我没有被授权。而我拥有该项目的所有权利,并且我是该项目的所有者。

补充:我可以触发其他非手工作业,但不能触发这个。我还提到: https ://gitlab.com/gitlab-org/gitlab-ce/issues/22824

可能有什么问题?我该如何解决这个问题?

4

1 回答 1

0

我似乎已经找到了解决方案:

  • 您需要在 API 调用中添加作业范围
  • 此外,仅当您取消了该管道中的工作时,重试方法才会起作用。

你可以试试:

curl --header "PRIVATE-TOKEN: xxxxx" 'https://gitlab.example.com/api/v4/projects/1/jobs?scope[]=pending&scope[]=running'

然后指定是否要播放/重试作业。

于 2017-07-19T18:28:26.530 回答