Asynchronous library of Jenkins API based on aiohttp
Project description
aiojenkins
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)
- 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(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_output(name: str, build_id: int) -> str
- is_exists(name: str, build_id: int) -> bool
- start(name: str, parameters: dict = None, delay: int = 0)
- stop(name: str, build_id: int)
- delete(name: str, build_id: int)
Project details
Release history Release notifications | RSS feed
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.3.1.tar.gz
(10.0 kB
view hashes)
Built Distribution
aiojenkins-0.3.1-py3-none-any.whl
(14.3 kB
view hashes)
Close
Hashes for aiojenkins-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcb981064745024984f51055b1aabf39bb4d807484b6a4a867345a91a2c4286b |
|
MD5 | d953f5b22f334c59b77bedecec8a6277 |
|
BLAKE2b-256 | 8b57e7022690b848482f54711f0015ba2535ece7949f74b6dc93e91dd90977a5 |