【问题标题】:How to get build status from GitLab CI?如何从 GitLab CI 获取构建状态?
【发布时间】:2013-02-26 19:49:50
【问题描述】:

我想从GitLab CI 添加上限部署场景检查构建状态。

有可能吗?

GitLab CI 是否有一些 API 可以通过提交 SHA 来获取构建/管道状态?

【问题讨论】:

  • 我在他们的构建徽章 URL 上没有找到任何好的文档。如果有人有链接,请发布。

标签: gitlab


【解决方案1】:

GitLab CI基于Travis,提供build status url,甚至构建状态图:

https://travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png
# or, limited to some branches
https://travis-ci.org/[YOUR_GITHUB_USERNAME]/[YOUR_PROJECT_NAME].png?branch=master,staging,production

Joran Beasley 提到网址:

http://gitlabci.example.com/projects/2/status.png?ref=master

【讨论】:

  • 他们的文档在这方面非常糟糕。上面 Joran 的 URL 确实有效。
  • @aglassman 好点。我已将 Joran 的评论包含在答案中以获得更多可见性。
【解决方案2】:

我找到了这样的链接http://some.domain/projects/:ID/builds/:SHA/status。 问题解决了

【讨论】:

【解决方案3】:

现在您可以从此网址获取徽章:

https://gitlab.com/[namespace]/[project]/badges/[branch]/pipeline.svg

【讨论】:

    【解决方案4】:

    你可以在Pipelines settings页面找到构建徽章信息,即

    https://<your-gitlab-installation-domain>/<group-name>/<repository-name>/settings/ci_cd
    

    对于特定的存储库:

    1. 转到设置 > CI/CD
    2. 展开常规管道设置部分
    3. 向下滚动到管道状态和/或覆盖报告
    4. 选择您的分支
    5. 复制您需要的任何内容(可能是 Markdown)

    参考见:

    【讨论】:

      【解决方案5】:

      API

      从 GitLab 8.1 开始,有了新的提交状态 API。

      GitLab CI Commits APIv4:

      List the statuses of a commit

      curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/17/repository/commits/18f3e63d05582537db6d183d9d557be09e1f90c8/statuses
      

      附: GitLabs 令牌在 Personal Access Tokens 页面 (https://gitlab.example.com/profile/personal_access_tokens) 中进行管理

      glablab

      有两个很棒的工具可以使用GitLab

      glablab 都是开源工具,其目标相同是将 GitLab 引入命令行并简化开发人员工作流程。在很多方面labhubglabgh

      lab 旨在让git 用户感到熟悉,并利用git 来支持它的许多命令。 glabgh 用户来说会感觉更熟悉,并且因此更具交互性并且可能对初学者更友好。

      lab ci status

      对于带有lab 的 CI 管道的文本表示,您可能需要:

      lab ci status [branch] [flags]
      

      示例

      lab ci status
      lab ci status upstream 608 --merge-request
      lab ci status 600 --wait
      lab ci status upstream 125 --merge-request --bridge 'security-tests'
      

      glab pipeline status

      对于带有glab 的 CI 管道的文本表示,您可能需要:

      glab pipeline status \[flags\]

      示例

      $ glab pipeline status --live
      $ glab pipeline status --branch=master   // Get pipeline for master branch
      $ glab pipe status   // Get pipeline for current branch
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-08-05
        • 2021-02-11
        • 1970-01-01
        • 1970-01-01
        • 2013-10-27
        • 2015-10-07
        • 2017-06-10
        • 1970-01-01
        相关资源
        最近更新 更多