Skip to main content

A package for reading Jenkinsfile-like pipeline files

Project description

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

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

  • Parse pipeline file
  • 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

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

pipeline-reader-0.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipeline_reader-0.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file pipeline-reader-0.0.1.tar.gz.

File metadata

  • Download URL: pipeline-reader-0.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

File hashes

Hashes for pipeline-reader-0.0.1.tar.gz
Algorithm Hash digest
SHA256 57cad505cfb3039dfe6eb38ce6264c694576c29cac404490aceb5010d04c45bb
MD5 1aad76a75d88132e8653ba0e8b871ab0
BLAKE2b-256 508be736ed902f7b87eece31ad3700e3bb9c27124cd4d90f2c2331eb99bb0139

See more details on using hashes here.

File details

Details for the file pipeline_reader-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pipeline_reader-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2

File hashes

Hashes for pipeline_reader-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b59319d70a4c11fc2dc36c46906fa86d3dba186b929107f625eb640b28b8c6e
MD5 48a2ac49c043e35af473158d0ca0b527
BLAKE2b-256 bcb5a9821afcbe510979e9e178860e8c52d8d50a7091cb15d0cd2e1c7d9b67d0

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