Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change pipeline badge name

As the standard pipeline badge from GitLab looks like this

enter image description here

you can tell pretty well that those are not really distinguishable.

Is there a way to change the pipeline text manually or programmatically to something else for each badge?

Btw, the badges were added with those links

https://gitlab.com/my-group/my-repository/badges/master/pipeline.svg
https://gitlab.com/my-group/my-repository/badges/dev/pipeline.svg

Additional facts:

  • The pipeline runs locally on my computer
  • My repo is private
like image 263
Hille Avatar asked Apr 24 '19 18:04

Hille


2 Answers

I know it is a bit of an old post, but I was looking for the same and found that it is available now since GitLab 13.1.

The text for a badge can be customized to differentiate between multiple coverage jobs that run in the same pipeline. Customize the badge text and width by adding the key_text=custom_text and key_width=custom_key_width parameters to the URL:

https://gitlab.com/gitlab-org/gitlab/badges/main/coverage.svg?job=karma&key_text=Frontend+Coverage&key_width=130

The example is for the Coverage badge but this also works for Pipelines, so in your case:

https://gitlab.com/my-group/my-repository/badges/master/pipeline.svg?key_text=master&key_width=50
https://gitlab.com/my-group/my-repository/badges/dev/pipeline.svg?key_text=dev&key_width=50

(Found this via https://microfluidics.utoronto.ca/gitlab/help/ci/pipelines/settings.md#custom-badge-text)

like image 68
cvuik Avatar answered Oct 11 '22 16:10

cvuik


There are multiple ways how you can achieve custom pipeline badges in GitLab.

One way could be to use Shields.io which provide a way to generate dynamic badges for your Gitlab repository via a jsonfile.But if your repository is private (only accessible from internal network) then you will get an inaccessible message in your badges.

Otherwise, if your build uses python Docker images or any other python installation with dependencies, you can simply install the anybadge package and generate svg badges to be used in the project from the artifacts directly.

It would be good in future that GitLab offers us more cleaner way to customize the badges, but for now I think those are the workaround solutions.

like image 35
Filip Ajdačić Avatar answered Oct 11 '22 16:10

Filip Ajdačić