Skip to main content

Service to share GitLab scheduled job statuses with badges

Project description

GitLab Schedule Badge

The following project provides the means to generate badges based on the status of a GitLab project's scheduled job. This tool can be used to host a website that presents users the option to pass in a GitLab project URL. Users can then request available scheduled pipelines for the project and the page will provide badge links that can be used in other documentation.

Requirements

Installation

Manual

This tool can be installed using pip:

pip install gitlab-schedule-badge
 (or)
python -m pip install gitlab-schedule-badge

For an initial setup/testing, users can start the application from the command line:

gitlab-schedule-badge --help
 (or)
python -m gitlab_schedule_badge --help

Running the instance will require a configuration to be prepared (discussed below).

When looking to deploy this tool for production use, there are various ways to use this application. This application uses the following for WSGI startup:

  • Module: gitlab_schedule_badge.wsgi
  • Call: main

For example, users can use Gunicorn as follows:

gunicorn --bind 0.0.0.0 "gitlab_schedule_badge.wsgi:main()"

Docker

This project supports multiple ways to use this utility inside a Docker environment. A recommended choice is to use a pre-built image available from GitLab's container registry.

Pre-built image

A pre-built image can be acquired using the following command:

docker pull registry.gitlab.com/gitlab-schedule-badge/gitlab-schedule-badge:0.2.0

Prepare a configuration for this container by creating a file /etc/gitlab-schedule-badge.toml with the contents defined in the configuration template (users can use any path or filename they desire, as long as the following docker run command points to this file). Adjust these options to the configuration desired.

The container than can be run using the following command:

docker run \
    --name gitlab-schedule-badge \
    --detach \
    --publish 8080:8000 \
    --restart unless-stopped \
    --volume /etc/gitlab-schedule-badge.toml:/etc/gitlab-schedule-badge.toml \
    registry.gitlab.com/gitlab-schedule-badge/gitlab-schedule-badge:0.2.0

Feel free to change the value of 8080 to a more preferred port value.

Self-managed Docker Compose

Users can also take advantage of the Docker compose definition. First, copy the contents in this repository's docker/ folder to a desired location.

Next, load up the container using docker compose from within the folder:

docker compose build
docker compose up --detach

Both Docker build calls will by default load a container with the PyPI version of gitlab-schedule-badge. Users wanting to use the local implementation in their container can do so by performing a Docker build with the --build-arg local argument.

For example:

docker compose build --build-arg BUILD_MODE=local
docker compose up --detach

Configuration

Configuration is performed using a gitlab-schedule-badge.toml file.

An example of a bare minimum configuration is as follows:

[[gitlab-schedule-badge-instance]]
url = 'https://git.example.com/'
token = 'glpat-value'
  1. Define a GitLab instance with the [[gitlab-schedule-badge-instance]] section.
  2. Specifies the GitLab instance that API requests will be made to.
  3. Specifies the token used to authenticate API requests.

The token can be either a personal access token, a project access token or a group access token. Only projects which the token has access to can query the scheduled pipeline information for said projects. A token only requires the read_api scope. For project/group access tokens, only the Guest role is required if the project is public. For private projects/groups, a role of Reporter may be required.

Multiple instances can be added by adding additional instance sections. For example, the following configuration supports querying projects from two GitLab self-hosted instances:

[[gitlab-schedule-badge-instance]]
url = 'https://git.example.com/'
token = 'glpat-value1'

[[gitlab-schedule-badge-instance]]
url = 'https://git.example.org/'
token = 'glpat-value2'

Users can also define group or project-specific keys to apply on an instance:

[[gitlab-schedule-badge-instance]]
url = 'https://git.example.com/'
namespace = 'group-a'
token = 'glpat-value1'

[[gitlab-schedule-badge-instance]]
url = 'https://git.example.com/'
namespace = 'group-b'
token = 'glpat-value2'

With a configuration prepared, a user can validate this tool can query configured GitLab instances using the following command:

gitlab-schedule-badge --api-check

See the configuration template for more details.

Troubleshooting

"Project Not Found"

If GitLab reports that a project cannot be found, this is either two things:

  1. The project does not exist. Sanity check that the project path is valid.
  2. Access to the project is not permitted with the provided token. Verify the token created is done by a user who has access to the specific project, or is created for project (or container group) being queried.

Reverse Proxy with NGINX

If running this tool behind an NGINX reverse proxy, ensure that:

  1. Ensure appropriate X-Forwarded-* headers are set.
  2. Configure both the server-name and reverse-proxy-chain entries in configuration file (gitlab-schedule-badge.toml).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlab_schedule_badge-0.3.0.tar.gz (55.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitlab_schedule_badge-0.3.0-py3-none-any.whl (60.4 kB view details)

Uploaded Python 3

File details

Details for the file gitlab_schedule_badge-0.3.0.tar.gz.

File metadata

  • Download URL: gitlab_schedule_badge-0.3.0.tar.gz
  • Upload date:
  • Size: 55.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for gitlab_schedule_badge-0.3.0.tar.gz
Algorithm Hash digest
SHA256 23635b3dc4db432dbb5bc4d2219ce1a31ec898ef7fea96f47ff707ca7b43f405
MD5 357430b69df7d5c98647a76c06561ec1
BLAKE2b-256 b95ffe3c40a79e215d5b1ee957f16d4c7860dda1132faaa6fe551ec61aab52dc

See more details on using hashes here.

File details

Details for the file gitlab_schedule_badge-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gitlab_schedule_badge-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56ae39248f84ae8a74862e9b6964971be21d7d0e8e6ae37642fecfb1ec1a7b84
MD5 e186ca2d44d00df777c4ce0f81a96582
BLAKE2b-256 28e455e1c6f5e55cc8360d5d385daa61fd0c587c2eb9bff5770e5deb90130e93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page