Skip to main content

The Gitlab CI Python Library

Project description

gcip - The Gitlab CI Python Library

A Python Library for creating dynamic pipelines for Gitlab CI.

User Documentation | API Reference

With the gcip and the ease and power of Python you can write Gitlab CI pipelines of any complexity in well manageable Python code.

A simple starting pipeline could look like following:

from gcip import Pipeline, Job

pipeline = Pipeline()
pipeline.add_children(Job(namespace="build", script="docker build ."))
pipeline.write_yaml()

Here is a prospect of how you can handle complex pipelines in Python:

from gcip import Pipeline, JobSequence, Job
from gcip.addons.gitlab import job_scripts as gitlab


def get_build_deploy_sequence(environment: str):
    return JobSequence().add_children(
        Job(namespace="build", script=f"docker build -t myimage-{environment} ."),
        Job(namespace="deploy", script=["docker login", f"docker push myimage-{environment}"]),
    )


pipeline = Pipeline()
pipeline.initialize_image("my/enterprise/build-image:stable")

for environment in ("develop", "test", "production"):
    jobs = get_build_deploy_sequence(environment)
    jobs.prepend_scripts(
        gitlab.clone_repository(path="projectx/configuration", branch=environment),
        f"source {environment}.env",
    )
    jobs.add_tags(environment)

    pipeline.add_children(jobs, namespace=environment)

pipeline.write_yaml("generated-config.yml")

Do you really want to see the generated-config.yml ? :)

Documentation

Please read the User Documentation to get a quick introduction into most features of the gcip.

You can consult the API Reference to get an overview of all classes and methods and a deeper view into their paramters.

Why is this Gitlab Project hosted on Github?

The DB Systel GmbH organization sponsoring this project is currently only present on Github. This may be change in future.

Author

gcip was created by Thomas Steinbach in 2020.

Thanks to initial contributions from Daniel von Eßen

Licence

The content of this repository is licensed under the Apache 2.0 license.

Copyright DB Systel GmbH

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gcip-0.6.1-py3-none-any.whl (56.9 kB view hashes)

Uploaded Python 3

Supported by

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