pipeline-reader


Namepipeline-reader JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/jfcarter2358/pipeline-reader
SummaryA package for reading Jenkinsfile-like pipeline files
upload_time2021-07-27 01:22:11
maintainer
docs_urlNone
authorJohn Carter
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pipeline Reader

## About

`pipeline-reader` is a package designed to make it easier to user Jenkinsfile-like pipeline files in Python projects. While JSON and YAML are generally sufficient for this task, there may be times where you want to execute code, which JSON and YAML are not well-suited for. In this case, pipeline-reader allows you to define stages containing Python code which are then run sequentially.

## Examples

### Writing a Pipeline

A basic pipeline consists of a pipeline block containing stages as follows:
```
pipeline {
    stages {
        stage('foo') {
            print('do something')
        }
    }
}
```
You can then add an options block like so
```
pipeline {
    options {
        "foo1": "bar1"
        "foo2": "bar2"
    }
    stages {
        stage('foo') {
            print('do something')
        }
    }
}
```
These options will then be stored in a dictionary and made available via the Pipeline object that `pipeline-reader` returns
In addition, the code context carries over between stages, so running
```
pipeline {
    stages {
        stage('foo') {
            variable = True
        }
        stage('bar') {
            print(variable)
        }
    }
}
```
will output `True`.
Finally, Python and C style comments are both supported inside the pipeline files.
```
# this will be ignored when the file is loaded in
pipeline {
    stages {
        // this will also be ignored
        stage('foo') {
            # even comments inside of stages are stripped out
            print('do something')
        }
    }
}
```

### Using `pipeline-reader` in an Application
To utilize `pipeline-reader`, you'll want to use something like what is shown below

```Python
import pipeline_reader

# this will load your pipeline
with open('filename.pipeline') as f:
    pipeline = pipeline_reader.load(f)

# this will execute your pipeline
pipeline_reader.run(pipeline, globals(), locals())

```
## To Do

- [x] Parse pipeline file
- [x] Run loaded pipelines
- [ ] Pre-stage
- [ ] Post-stage
- [ ] Catch stage success
- [ ] Catch stage failure
- [ ] Allow loading of arbitrary block types

## Contact

If you have any questions or concerns, please reach out to me (John Carter) at jfcarter2358@gmail.com


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jfcarter2358/pipeline-reader",
    "name": "pipeline-reader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "John Carter",
    "author_email": "jfcarter2358@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/50/8b/e736ed902f7b87eece31ad3700e3bb9c27124cd4d90f2c2331eb99bb0139/pipeline-reader-0.0.1.tar.gz",
    "platform": "",
    "description": "# Pipeline Reader\n\n## About\n\n`pipeline-reader` is a package designed to make it easier to user Jenkinsfile-like pipeline files in Python projects. While JSON and YAML are generally sufficient for this task, there may be times where you want to execute code, which JSON and YAML are not well-suited for. In this case, pipeline-reader allows you to define stages containing Python code which are then run sequentially.\n\n## Examples\n\n### Writing a Pipeline\n\nA basic pipeline consists of a pipeline block containing stages as follows:\n```\npipeline {\n    stages {\n        stage('foo') {\n            print('do something')\n        }\n    }\n}\n```\nYou can then add an options block like so\n```\npipeline {\n    options {\n        \"foo1\": \"bar1\"\n        \"foo2\": \"bar2\"\n    }\n    stages {\n        stage('foo') {\n            print('do something')\n        }\n    }\n}\n```\nThese options will then be stored in a dictionary and made available via the Pipeline object that `pipeline-reader` returns\nIn addition, the code context carries over between stages, so running\n```\npipeline {\n    stages {\n        stage('foo') {\n            variable = True\n        }\n        stage('bar') {\n            print(variable)\n        }\n    }\n}\n```\nwill output `True`.\nFinally, Python and C style comments are both supported inside the pipeline files.\n```\n# this will be ignored when the file is loaded in\npipeline {\n    stages {\n        // this will also be ignored\n        stage('foo') {\n            # even comments inside of stages are stripped out\n            print('do something')\n        }\n    }\n}\n```\n\n### Using `pipeline-reader` in an Application\nTo utilize `pipeline-reader`, you'll want to use something like what is shown below\n\n```Python\nimport pipeline_reader\n\n# this will load your pipeline\nwith open('filename.pipeline') as f:\n    pipeline = pipeline_reader.load(f)\n\n# this will execute your pipeline\npipeline_reader.run(pipeline, globals(), locals())\n\n```\n## To Do\n\n- [x] Parse pipeline file\n- [x] Run loaded pipelines\n- [ ] Pre-stage\n- [ ] Post-stage\n- [ ] Catch stage success\n- [ ] Catch stage failure\n- [ ] Allow loading of arbitrary block types\n\n## Contact\n\nIf you have any questions or concerns, please reach out to me (John Carter) at jfcarter2358@gmail.com\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A package for reading Jenkinsfile-like pipeline files",
    "version": "0.0.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "48a2ac49c043e35af473158d0ca0b527",
                "sha256": "2b59319d70a4c11fc2dc36c46906fa86d3dba186b929107f625eb640b28b8c6e"
            },
            "downloads": -1,
            "filename": "pipeline_reader-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48a2ac49c043e35af473158d0ca0b527",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5161,
            "upload_time": "2021-07-27T01:22:10",
            "upload_time_iso_8601": "2021-07-27T01:22:10.260346Z",
            "url": "https://files.pythonhosted.org/packages/bc/b5/a9821afcbe510979e9e178860e8c52d8d50a7091cb15d0cd2e1c7d9b67d0/pipeline_reader-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1aad76a75d88132e8653ba0e8b871ab0",
                "sha256": "57cad505cfb3039dfe6eb38ce6264c694576c29cac404490aceb5010d04c45bb"
            },
            "downloads": -1,
            "filename": "pipeline-reader-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1aad76a75d88132e8653ba0e8b871ab0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3492,
            "upload_time": "2021-07-27T01:22:11",
            "upload_time_iso_8601": "2021-07-27T01:22:11.425114Z",
            "url": "https://files.pythonhosted.org/packages/50/8b/e736ed902f7b87eece31ad3700e3bb9c27124cd4d90f2c2331eb99bb0139/pipeline-reader-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-07-27 01:22:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "jfcarter2358",
    "github_project": "pipeline-reader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "pipeline-reader"
}
        
Elapsed time: 0.27828s