首页 > 解决方案 > How to update gitlab badges during CI without using personal access token

问题描述

How to update gitlab badges during the CI without using a personal access token?

I have version badge and want to update it after every build. Therefore, I use maven to get the current version and update the badge using the API.

curl --silent --request PUT --header "Private-Token: $GITLAB_API_TOKEN" https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/badges/1 -d image_url=https://img.shields.io/badge/version-${VERSION}-blue.svg

However, the GITLAB_API_TOKEN has to be a personal access token. Saving the GITLAB_API_TOKEN in the repository variables allows other developers to access the variable. Therefore, a developer can use another developers personal access key.

Is there another option to update gitlab project badges?

Update: there is a gitlab issue regarding this feature: https://gitlab.com/gitlab-org/gitlab/-/issues/15666

标签: gitlabbadge

解决方案


检查您是否仍需要进行该更新,或者GitLab 14.8(2022 年 2 月)是否为您完成

项目的最新发布徽章

我们添加了一个新徽章,因此您可以直接在项目页面中轻松查看最新版本的版本。

感谢Jason D'Amour的贡献!

https://about.gitlab.com/images/14_8/release-latest-release-badge.png -- 项目的最新发布徽章

请参阅文档问题


推荐阅读