gcip


Namegcip JSON
Version 3.0.4 PyPI version JSON
download
home_pagehttps://gitlab.com/dbsystel/gitlab-ci-python-library
SummaryThe Gitlab CI Python Library
upload_time2024-03-05 14:38:44
maintainer
docs_urlNone
authorThomas Steinbach
requires_python~=3.10
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pipeline status](https://gitlab.com/dbsystel/gitlab-ci-python-library/badges/main/pipeline.svg)](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/commits/main)
[![coverage report](https://gitlab.com/dbsystel/gitlab-ci-python-library/badges/main/coverage.svg)](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/commits/main)
[![Downloads](https://pepy.tech/badge/gcip)](https://pepy.tech/project/gcip)

# gcip - Write your Gitlab CI pipelines in Python

The Gitlab CI Python Library (gcip) is a Library to create dynamic pipelines for Gitlab CI.

[User Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/user/index.html) | [API Reference](https://dbsystel.gitlab.io/gitlab-ci-python-library/api/gcip/index.html) | [Developer Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/developer/index.html) | [PyPI](https://pypi.org/project/gcip/) | [Docker Hub](https://hub.docker.com/r/thomass/gcip)

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()
job      = Job(stage="build", script="docker build .")

pipeline.add_children(job)
pipeline.write_yaml()
```

For a more complex and real world example, just check out [.gitlab-ci.py](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/blob/main/.gitlab-ci.py). This is the Python Gitlab CI pipeline of this project written with its own library. And second check out the [generated yaml file](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/jobs/artifacts/main/browse?job=generate-pipeline) of the Python code.

The gcip is using the Gitlab feature of [dynamic child pipelines](https://docs.gitlab.com/ee/ci/parent_child_pipelines.html#dynamic-child-pipelines). First the `.gitlab-ci.py` generates the common Gitlab CI yaml file which is then started as child pipeline.

Creating your pipelines in Python code allows you all the features of that language, like:

* re-use code (DRY - Dont Repeat Yourself)
* use variables, control flow (if-then-else, loops, ...), complex data structures, input/output, error handling, ...
* programming paradigms like object-oriented or functional programming
* use 3rd party libraries in your pipelines, like boto3
* test driven development of Pipelines with pytest
* package management and distribution of your pipeline code
* ... anything you can imagine to do with Python code

## Documentation

Please read the [User Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/user/index.html) to get a quick introduction into most
features of the gcip.

You can consult the [API Reference](https://dbsystel.gitlab.io/gitlab-ci-python-library/api/gcip/index.html) to get an overview of all classes and methods
and a deeper view into their parameters.

For more information on how to create your own library based on gcip, please read the [Developer Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/developer/index.html)
to learn about good practices and conventions.

## Why pipelines as code?

There has been a really good discussion on [Hacker News](https://news.ycombinator.com/item?id=26986493#26988105) about _configuration vs code_.
Comments stating that when struggeling around with the limitations of static configuration we start writing pipelines as code, until we hassle
around with complex code and start re-writing complex pipelines in static configuration and so forth.

It is absolutely right that piplines as code are not new and have lots of drawbacks. Chances are good that you have the one guru in you company
loving this project and is writing weird piplines that nobody else understands. Also comments state that pipelines are those basic things that
build and test your code and shouldn't be in code too, because then you might have a pipeline that build and test your pipeline code.

All those statements are quite true. However all those statements could be applied to static configuration. We started this project because of
Gitlab CI yaml files growing over thousands of lines. We tried to implement some logic with clunky rule sets. We tried to re-use code with yaml templates.
We tried to write predefined pipelines by using includes. We started to write bash scripts that do bulk loads of work within a job. All in all
those felt like a bad workaround, while having in mind how much cleaner this might be, writing our pipelines in code. That is why we started
this project and since using it with great success.

However it is absolutely important to understand the gcip as a supplement and not as a substitution to Gitlab CI yaml files. As long you are fine
with having a couple of jobs you could easily describe in static configuration, just do it. If you feel that you can't manage the complexity of
you static yaml configuration and started to build lots of helper scripts, you could consider writing your pipelines in code. This considerations
should include, if the pipeline code you write is definitly an advantage over the static scripts you had before - and not just for you but also
for your colleagues and the company you are writing the code for.

The gcip should be a choice - not a standard.

## Author

gcip was created by [Thomas Steinbach](mailto:thomas.t.steinbach@deutschebahn.com) in 2020.

Thanks to initial contributions from [Daniel von Eßen](mailto:daniel.von-essen@deutschebahn.com)

## Licence

The content of this repository is licensed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).

Copyright DB Systel GmbH

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/dbsystel/gitlab-ci-python-library",
    "name": "gcip",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.10",
    "maintainer_email": "",
    "keywords": "",
    "author": "Thomas Steinbach",
    "author_email": "thomas.t.steinbach@deutschebahn.com",
    "download_url": "",
    "platform": null,
    "description": "[![pipeline status](https://gitlab.com/dbsystel/gitlab-ci-python-library/badges/main/pipeline.svg)](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/commits/main)\n[![coverage report](https://gitlab.com/dbsystel/gitlab-ci-python-library/badges/main/coverage.svg)](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/commits/main)\n[![Downloads](https://pepy.tech/badge/gcip)](https://pepy.tech/project/gcip)\n\n# gcip - Write your Gitlab CI pipelines in Python\n\nThe Gitlab CI Python Library (gcip) is a Library to create dynamic pipelines for Gitlab CI.\n\n[User Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/user/index.html) | [API Reference](https://dbsystel.gitlab.io/gitlab-ci-python-library/api/gcip/index.html) | [Developer Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/developer/index.html) | [PyPI](https://pypi.org/project/gcip/) | [Docker Hub](https://hub.docker.com/r/thomass/gcip)\n\nWith the gcip and the ease and power of Python you can write Gitlab CI pipelines\nof any complexity in well manageable Python code.\n\nA simple starting pipeline could look like following:\n\n```\nfrom gcip import Pipeline, Job\n\npipeline = Pipeline()\njob      = Job(stage=\"build\", script=\"docker build .\")\n\npipeline.add_children(job)\npipeline.write_yaml()\n```\n\nFor a more complex and real world example, just check out [.gitlab-ci.py](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/blob/main/.gitlab-ci.py). This is the Python Gitlab CI pipeline of this project written with its own library. And second check out the [generated yaml file](https://gitlab.com/dbsystel/gitlab-ci-python-library/-/jobs/artifacts/main/browse?job=generate-pipeline) of the Python code.\n\nThe gcip is using the Gitlab feature of [dynamic child pipelines](https://docs.gitlab.com/ee/ci/parent_child_pipelines.html#dynamic-child-pipelines). First the `.gitlab-ci.py` generates the common Gitlab CI yaml file which is then started as child pipeline.\n\nCreating your pipelines in Python code allows you all the features of that language, like:\n\n* re-use code (DRY - Dont Repeat Yourself)\n* use variables, control flow (if-then-else, loops, ...), complex data structures, input/output, error handling, ...\n* programming paradigms like object-oriented or functional programming\n* use 3rd party libraries in your pipelines, like boto3\n* test driven development of Pipelines with pytest\n* package management and distribution of your pipeline code\n* ... anything you can imagine to do with Python code\n\n## Documentation\n\nPlease read the [User Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/user/index.html) to get a quick introduction into most\nfeatures of the gcip.\n\nYou can consult the [API Reference](https://dbsystel.gitlab.io/gitlab-ci-python-library/api/gcip/index.html) to get an overview of all classes and methods\nand a deeper view into their parameters.\n\nFor more information on how to create your own library based on gcip, please read the [Developer Documentation](https://dbsystel.gitlab.io/gitlab-ci-python-library/developer/index.html)\nto learn about good practices and conventions.\n\n## Why pipelines as code?\n\nThere has been a really good discussion on [Hacker News](https://news.ycombinator.com/item?id=26986493#26988105) about _configuration vs code_.\nComments stating that when struggeling around with the limitations of static configuration we start writing pipelines as code, until we hassle\naround with complex code and start re-writing complex pipelines in static configuration and so forth.\n\nIt is absolutely right that piplines as code are not new and have lots of drawbacks. Chances are good that you have the one guru in you company\nloving this project and is writing weird piplines that nobody else understands. Also comments state that pipelines are those basic things that\nbuild and test your code and shouldn't be in code too, because then you might have a pipeline that build and test your pipeline code.\n\nAll those statements are quite true. However all those statements could be applied to static configuration. We started this project because of\nGitlab CI yaml files growing over thousands of lines. We tried to implement some logic with clunky rule sets. We tried to re-use code with yaml templates.\nWe tried to write predefined pipelines by using includes. We started to write bash scripts that do bulk loads of work within a job. All in all\nthose felt like a bad workaround, while having in mind how much cleaner this might be, writing our pipelines in code. That is why we started\nthis project and since using it with great success.\n\nHowever it is absolutely important to understand the gcip as a supplement and not as a substitution to Gitlab CI yaml files. As long you are fine\nwith having a couple of jobs you could easily describe in static configuration, just do it. If you feel that you can't manage the complexity of\nyou static yaml configuration and started to build lots of helper scripts, you could consider writing your pipelines in code. This considerations\nshould include, if the pipeline code you write is definitly an advantage over the static scripts you had before - and not just for you but also\nfor your colleagues and the company you are writing the code for.\n\nThe gcip should be a choice - not a standard.\n\n## Author\n\ngcip was created by [Thomas Steinbach](mailto:thomas.t.steinbach@deutschebahn.com) in 2020.\n\nThanks to initial contributions from [Daniel von E\u00dfen](mailto:daniel.von-essen@deutschebahn.com)\n\n## Licence\n\nThe content of this repository is licensed under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0).\n\nCopyright DB Systel GmbH\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "The Gitlab CI Python Library",
    "version": "3.0.4",
    "project_urls": {
        "Homepage": "https://gitlab.com/dbsystel/gitlab-ci-python-library"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45a6d1d8a525885357d679ebb281a173254b2a29a9e6eb633850d1d005be41be",
                "md5": "b751f7bbe2f9e16c6ef60a2d56112d45",
                "sha256": "22d06d63f051ca1a7780918feaecd74ff89aa42abf288571cfc00bfc491fd4b4"
            },
            "downloads": -1,
            "filename": "gcip-3.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b751f7bbe2f9e16c6ef60a2d56112d45",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.10",
            "size": 95443,
            "upload_time": "2024-03-05T14:38:44",
            "upload_time_iso_8601": "2024-03-05T14:38:44.159516Z",
            "url": "https://files.pythonhosted.org/packages/45/a6/d1d8a525885357d679ebb281a173254b2a29a9e6eb633850d1d005be41be/gcip-3.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 14:38:44",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "dbsystel",
    "gitlab_project": "gitlab-ci-python-library",
    "lcname": "gcip"
}
        
Elapsed time: 0.21626s