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/jdknight/gitlab-schedule-badge:latest

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/jdknight/gitlab-schedule-badge:latest

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.

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.2.0.tar.gz (55.3 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.2.0-py3-none-any.whl (60.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gitlab_schedule_badge-0.2.0.tar.gz
Algorithm Hash digest
SHA256 832d27a0ef47a68dd352c14f6898903bc962c4f14b08d9ee38fbf6b6c66adc15
MD5 c983a48ffd78991acc5c930c40a0c802
BLAKE2b-256 76d15d2aa6c9102aefd75830b1d6a62ff8bb5bc37ddcd8e0d0db1aa4c4754fba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gitlab_schedule_badge-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87683285f536f82496fb65d53616c44c129de2aeffe8e12c19420370978662da
MD5 0f3e72f6bf02c0448145b56d2d87335d
BLAKE2b-256 b992a55673e52441e3368af4478eeb4fc5ec104521e5faf63a97efa3fb42268d

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