The gitlab_project_badge
resource allows to manage the lifecycle of project badges.
Upstream API: GitLab REST API docs
resource "gitlab_project" "foo" {
name = "foo-project"
}
resource "gitlab_project_badge" "example" {
project = gitlab_project.foo.id
link_url = "https://example.com/badge-123"
image_url = "https://example.com/badge-123.svg"
name = "badge-123"
}
# Pipeline status badges with placeholders will be enabled
resource "gitlab_project_badge" "gitlab_pipeline" {
project = gitlab_project.foo.id
link_url = "https://gitlab.example.com/%%{project_path}/-/pipelines?ref=%%{default_branch}"
image_url = "https://gitlab.example.com/%%{project_path}/badges/%%{default_branch}/pipeline.svg"
name = "badge-pipeline"
}
# Test coverage report badges with placeholders will be enabled
resource "gitlab_project_badge" "gitlab_coverage" {
project = gitlab_project.foo.id
link_url = "https://gitlab.example.com/%%{project_path}/-/jobs"
image_url = "https://gitlab.example.com/%%{project_path}/badges/%%{default_branch}/coverage.svg"
name = "badge-coverage"
}
# Latest release badges with placeholders will be enabled
resource "gitlab_project_badge" "gitlab_release" {
project = gitlab_project.foo.id
link_url = "https://gitlab.example.com/%%{project_path}/-/releases"
image_url = "https://gitlab.example.com/%%{project_path}/-/badges/release.svg"
name = "badge-release"
}
image_url
(String) The image url which will be presented on project overview.link_url
(String) The url linked with the badge.project
(String) The id of the project to add the badge to.name
(String) The name of the badge.id
(String) The ID of this resource.rendered_image_url
(String) The image_url argument rendered (in case of use of placeholders).rendered_link_url
(String) The link_url argument rendered (in case of use of placeholders).Import is supported using the following syntax:
# GitLab project badges can be imported using an id made up of `{project_id}:{badge_id}`, e.g.
terraform import gitlab_project_badge.foo 1:3