Skip to main content

Universal (sync/async) Python client for Jenkins

Project description

Build status Docs status Coverage status Version status Downloads status


Python client for Jenkins which supports both sync and async syntax with same interface.

Comparison to other packages

Name

Sync

Async

Python

ujenkins

YES

YES

3.6+

aiojenkins

NO

YES

3.5+

python-jenkins

YES

NO

3.4+

jenkinsapi

YES

NO

3.4+

Installation

Latest release from PyPI

pip3 install ujenkins

Or latest developing version

pip3 install git+https://github.com/pbelskiy/ujenkins

Usage

Get Jenkins version using sync client:

from ujenkins import JenkinsClient

def example():
    client = JenkinsClient('http://server', 'user', 'password')
    version = client.system.get_version()
    print(version)

example()

With async client (be careful AsyncJenkinsClient must be called inside async function):

import asyncio
from ujenkins import AsyncJenkinsClient

async def example():
    client = AsyncJenkinsClient('http://server', 'user', 'password')
    version = await client.system.get_version()
    print(version)

asyncio.run(example())

Examples

In all code examples below client instance is created by:

from ujenkins import JenkinsClient
client = JenkinsClient('http://server', 'user', 'password')

Get timestamp of latest build:

client.builds.get_info('job', 'lastBuild')['timestamp']

Get url of started build:

item_id = client.builds.start('my_job')
while True:
    time.sleep(5)
    info = client.queue.get_info(item_id)
    if 'executable' in info:
        print(info['executable']['url'])
        break

Please look at tests directory for more examples.

Documentation

Read the Docs

Testing

Prerequisites: tox

Then just run tox, all dependencies and checks will run automatically

tox

Contributing

Any contributions are welcome!

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

ujenkins-0.7.2.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

ujenkins-0.7.2-py3-none-any.whl (31.3 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