Gitlab CI using Badges for each job

前端 未结 4 1807
Happy的楠姐
Happy的楠姐 2021-01-31 05:41

Let\'s say I have configured multiple jobs for a project like following:

build_win32:
  script: ...

build_ios:
  script: ...

unit_tests:
  script: ...

server_         


        
4条回答
  •  春和景丽
    2021-01-31 06:20

    I developed a workaround solution to real-time per-job badges. It can be easily modified into anything else.

    The example repo: ci-test/badges. There is also a complete walkthrough so I won't copy-paste it here.

    The core idea is (assuming you're now inside a running CI job):

    • Fetch a badge from web into a file.
    • Upload the badge file to some real-time storage from where it can be linked (e.g. Dropbox).

    Dropbox supports calling its API via HTTP requests (see this). Thus, all the above can be done using e.g. curl or Python requests - basic tools. You just need to pass the Dropbox access token as secret variable and save the file under the same name to overwrite the old badge.

    Then, you can then directly link the Dropbox badge wherever you need. There are some tricks to it so be sure to check my example repo if you want to use it. For me it works quite well and seems to be fast.

    The advantage of this method is that you don't have to mess with GitLab Pages. Instead of publishing on Pages you put it to Dropbox. That is a simple file transfer called by HTTP request. No more to that.

提交回复
热议问题