Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects

PyPI to Docker missing version

License: MIT Pipeline

Objective

This template is used to retrieve all versions of a package from PyPI and compare it to the version of the image in the registry. If the version of the image is missing, the job will create an artefact with the lowest version of the package missing in the registry, ready to be used for other jobs to build the image.

How to use it

Include the component/template

Add the following to your .gitlab-ci.yml file.

As a remote Template (recommended):

include:
    -   remote: 'https://gitlab.com/swepy/cicd-templates/pypi-to-docker-missing-version/-/raw/0.2.1/templates/pypi-to-docker-missing-version.yml'

As a local Template (if the template is local to the instance):

include:
    -   project: 'swepy/cicd-templates/pypi-to-docker-missing-version'
        ref: '0.2.1'
        file: 'templates/pypi-to-docker-missing-version.yml'

As a Component (beta and if the component is local to the instance):

include:
    -   component: $CI_SERVER_FQDN/swepy/cicd-templates/pypi-to-docker-missing-version/pypi-to-docker-missing-version@0.2.1

Customize job

You can customize the job by overriding specific keys. For example:

pypi_to_docker_missing_version:
    variables:
        SORT_CMD: grep -E "^[0-9]+(\.[0-9]+)*$" | sort -t. -k1,1n -k2,2n -k3,3n

Variables

You can customize the job by overriding the following variables:

Name Description Default
IMAGE_NAME Mandatory The name of the image. Should be "<org|user>/<repo>". ""
PACKAGE_INDEX_API_URL The URL of the API to retrieve the package index. https://pypi.org/pypi
PACKAGE_NAME The name of the package. "$CI_PROJECT_NAME"
REPOSITORIES_API_URL The URL of the API to retrieve the repositories. https://registry.hub.docker.com/v2/repositories
SORT_CMD The command to sort the versions. sort -V
TAGS The tags of the image to consider as already built. Used to exclude specific versions. ""