A good support for automatic generaded badges came out to be more complicated than expected (you can read about the reasons in detail [HERE](https://gitlab.com/gitlab-org/gitlab-ce/issues/50603)), but the final solution seems to be nice and good working.
Badges are generated with [anybadge](https://pypi.org/project/anybadge/) by the [THIS bash function](https://gitlab.version.fz-juelich.de/vis/jusense-cicd/blob/master/ci/ci_funcs.sh#L3). The generated badges of all CI Jobs are copied by the last CI Job "pages" to the artifact "pages".
The drawback of this approach is, that one a single Artifacts section is allowed in .gitlab-ce.yml. And this needs to be 'pages' in this case. All CI Jobs must share the same Artifacts. And one should better know the exact behaviour of Artifacts in GitLab:
If you use Artifacts you should better know the exact behaviour of Artifacts in GitLab:
Artifacts are ...
* ... a list of files and directories
...
...
@@ -222,9 +214,27 @@ Artifacts are ...
* ... saved on the GitLab server as a zip file.
* ... attached to a job after it completes
#### Badges
On the projects front-page badges show the status and more of the most important CI Jobs of the laste pipeline run on branch master.
A good support for automatic generaded badges came out to be more complicated than expected (you can read about the reasons in detail [HERE](https://gitlab.com/gitlab-org/gitlab-ce/issues/50603)), but the final solution seems to be nice and good working.
Badges are generated with [anybadge](https://pypi.org/project/anybadge/) by the [THIS bash function](https://gitlab.version.fz-juelich.de/vis/jusense-cicd/blob/master/ci/ci_funcs.sh#L3). The generated badges of all CI Jobs are copied by the last CI Job "pages" to the artifact "pages".
The drawback of this approach is, that one a single Artifacts section is allowed in .gitlab-ce.yml. And this needs to be 'pages' in this case. All CI Jobs must share the same Artifacts.
The artifact "pages" is published online by [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/). Therefore, for all CI Jobs a fixed URL is available to the latest generated badge.
An example URL is: http://vis.pages.jsc.fz-juelich.de/jusense-cicd/badges/badge_build-openmpi_%{default_branch}.svg
##### Badges based on data from GitLab-API
Certain informations on your project are available through the [GitLab-API](https://docs.gitlab.com/ee/api/README.html). With 'curl' one can ask GitLab for information and it will pass a JSON file. You can get the number of forks for example with
In this project we use the ability to add a badge showing the number of forks and open issues.
They are generated beside other badges in [ci/badge-static.sh](https://gitlab.version.fz-juelich.de/vis/jusense-cicd/blob/master/ci/badges-static.sh#20).
To include the badges to your project front-page, they can be set in Project->Settings->Badges like this: