Async python client for Jenkins
Asynchronous python package of Jenkins API endpoints based on aiohttp.
Also pay attention to brand new package with same API set but with sync and async interfaces:
https://github.com/pbelskiy/ujenkins
pip3 install aiojenkins
Start new build using aiojenkins.Jenkins as an async context manager (preferred):
import asyncio
import aiojenkins
async def example():
async with aiojenkins.Jenkins('http://your_server/jenkins', 'user', 'password') as jenkins:
await jenkins.builds.start('job_name', {'parameter': 'test'})
asyncio.run(example())
Or without an async context manager:
import asyncio
import aiojenkins
jenkins = aiojenkins.Jenkins('http://your_server/jenkins', 'user', 'password')
async def example():
try:
await jenkins.builds.start('job_name', {'parameter': 'test'})
finally:
jenkins.close()
asyncio.run(example())
Please look at tests directory for more examples.
Currently tests aren't using any mocking. I am testing locally with dockerized LTS Jenkins ver. 2.222.3
Prerequisites: docker, tox
docker run -d --name jenkins --restart always -p 8080:8080 jenkins/jenkins:lts docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword chromium http://localhost:8080 # create admin:admin tox
Feel free to PR