Skip to main content

Asynchronous library of Jenkins API based on aiohttp

Project description

aiojenkins

Tests Coveralls github PyPI - Downloads

Asynchronous python library of Jenkins API endpoints based on aiohttp 🥳

Initial version of aiojenkins. Public API is still unstable (work is in progress)

Minimal Python version is 3.6 due async await and f-strings.

The package is tested on below matrix:

  • CPython: 3.6, 3.7, 3.8
  • Jenkins LTS: 1.554, 2.60.3, latest

Installation

pip install aiojenkins

Usage

Start new build:

import asyncio
import aiojenkins

async def example():
    jenkins = aiojenkins.Jenkins('http://your_server/jenkins', 'login', 'password')
    await jenkins.builds.start('job_name', dict(parameter='test'))

asyncio.run(example())

Please look at tests directory for more examples.

Testing

Currently tests aren't using any mocking. I am testing locally with dockerized LTS Jenkins ver. 2.222.3

Prerequisites: docker, pytest pytest-cov pytest-asyncio

docker run -d --name jenkins --restart always -p 8080:8080 jenkins/jenkins:lts
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
python3 -m pytest -v --cov=aiojenkins --cov-report=term --cov-report=html

Contributing

Feel free to PR :)

Implemented API

  • jenkins
    • get_status() -> dict
    • get_version() -> JenkinsVersion
    • is_ready() -> bool
    • wait_until_ready()
    • quiet_down()
    • cancel_quiet_down()
    • restart()
    • safe_restart()
    • generate_token(name: str) -> Tuple[str, str]
    • revoke_token(token_uuid: str)
    • run_groovy_script(self, script: str) -> str
    • nodes
      • get_all() -> dict
      • get_info(name: str) -> dict
      • get_failed_builds(self, name: str) -> List[dict]
      • get_all_builds(self, name: str) -> List[dict]
      • get_config(name: str) -> str
      • is_exists(name: str) -> bool
      • construct(name: str, remote_fs: str = '/tmp', executors: int = 2) -> dict
      • create(name: str, config: dict)
      • delete(name: str)
      • enable(name: str)
      • disable(name: str, message: str = '')
      • update_offline_reason(name: str, message: str)
    • jobs
      • get_all() -> dict
      • get_info(name: str) -> dict
      • get_config(name: str) -> str
      • is_exists(name: str) -> bool
      • construct_config(description: str = None, parameters: List[dict] = None, commands: List[str] = None) -> str:
      • create(name: str, config: str)
      • delete(name: str)
      • copy(name: str, new_name: str)
      • rename(name: str, new_name: str)
      • enable(name: str)
      • disable(name: str)
    • builds
      • get_all(name: str) -> list
      • get_info(name: str, build_id: int) -> dict
      • get_url_info(url: str) -> dict
      • get_output(name: str, build_id: int) -> str
      • is_exists(name: str, build_id: int) -> bool
      • get_queue_id_info(self, queue_id: int) -> dict
      • start(name: str, parameters: dict = None, delay: int = 0) -> int
      • stop(name: str, build_id: int)
      • delete(name: str, build_id: int)
  • jenkins.utils
    • construct_job_config(*, description: str = None, parameters: List[dict] = None, commands: List[str] = None) -> str
    • construct_node_config(*, name: str, remote_fs: str = '/tmp', executors: int = 2) -> dict
    • parse_build_url(build_url) -> Tuple[str, int]

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

aiojenkins-0.4.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

aiojenkins-0.4.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file aiojenkins-0.4.1.tar.gz.

File metadata

  • Download URL: aiojenkins-0.4.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for aiojenkins-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d5b4ecc4eae5679b6b164409e69f50f13c4e52e13f4327d34de0c53e2df043ad
MD5 499dc12d8313577bcb1a6948ee3d06e7
BLAKE2b-256 4b5f7679897d252d0ef541e5dda593367ab070ab1d987a7b9e032d5b2bc8c787

See more details on using hashes here.

File details

Details for the file aiojenkins-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: aiojenkins-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

File hashes

Hashes for aiojenkins-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 483e78c263c1fc5507d335b1b18fbdf397026c4b7936a04bf49cf08ac52f3523
MD5 e357e9c73bec19e55c546be1a9836a0b
BLAKE2b-256 9c68bbbe23cb77fe380b73feed0cc2cba41e270a3239a19cdec3a9a4940c7f74

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