api4jenkins


Nameapi4jenkins JSON
Version 2.0.3 PyPI version JSON
download
home_pagehttps://github.com/joelee2012/api4jenkins
SummaryJenkins Python Client
upload_time2023-12-22 08:14:03
maintainer
docs_urlNone
authorJoe Lee
requires_python>=3.8
licenseApache 2.0
keywords restapi jenkins
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Unit Test](https://github.com/joelee2012/api4jenkins/actions/workflows/unittest.yml/badge.svg?branch=main)](https://github.com/joelee2012/api4jenkins/actions/workflows/unittest.yml)
[![Integration Test](https://github.com/joelee2012/api4jenkins/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/joelee2012/api4jenkins/actions/workflows/integration.yml)
![CodeQL](https://github.com/joelee2012/api4jenkins/workflows/CodeQL/badge.svg?branch=main)
[![codecov](https://codecov.io/gh/joelee2012/api4jenkins/branch/main/graph/badge.svg?token=YGM4CIB149)](https://codecov.io/gh/joelee2012/api4jenkins)
![PyPI](https://img.shields.io/pypi/v/api4jenkins)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api4jenkins)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/api4jenkins)
[![Documentation Status](https://readthedocs.org/projects/api4jenkins/badge/?version=latest)](https://api4jenkins.readthedocs.io/en/latest/?badge=latest)
![GitHub](https://img.shields.io/github/license/joelee2012/api4jenkins)


# Jenkins Python Client

[Python3](https://www.python.org/) client library for [Jenkins API](https://www.jenkins.io/doc/book/using/remote-access-api/) which provides sync and async APIs.

# Features

- Provides sync and async APIs
- Object oriented, each Jenkins item has corresponding class, easy to use and extend
- Base on `api/json`, easy to query/filter attribute of item
- Setup relationship between class just like Jenkins item
- Support api for almost every Jenkins item
- Pythonic
- Test with latest Jenkins LTS

# Installation

```bash
python3 -m pip install api4jenkins
```

# Quick start

Sync example:

```python
>>> from api4jenkins import Jenkins
>>> client = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
>>> client.version
'2.176.2'
>>> xml = """<?xml version='1.1' encoding='UTF-8'?>
... <project>
...   <builders>
...     <hudson.tasks.Shell>
...       <command>echo $JENKINS_VERSION</command>
...     </hudson.tasks.Shell>
...   </builders>
... </project>"""
>>> client.create_job('path/to/job', xml)
>>> import time
>>> item = client.build_job('path/to/job')
>>> while not item.get_build():
...      time.sleep(1)
>>> build = item.get_build()
>>> for line in build.progressive_output():
...     print(line)
...
Started by user admin
Running as SYSTEM
Building in workspace /var/jenkins_home/workspace/freestylejob
[freestylejob] $ /bin/sh -xe /tmp/jenkins2989549474028065940.sh
+ echo $JENKINS_VERSION
2.176.2
Finished: SUCCESS
>>> build.building
False
>>> build.result
'SUCCESS'
```

Async example

```python
import asyncio
import time
from api4jenkins import AsyncJenkins

async main():
    client = AsyncJenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))
    print(await client.version)
    xml = """<?xml version='1.1' encoding='UTF-8'?>
    <project>
      <builders>
        <hudson.tasks.Shell>
          <command>echo $JENKINS_VERSION</command>
        </hudson.tasks.Shell>
      </builders>
    </project>"""
    await client.create_job('job', xml)
    item = await client.build_job('job')
    while not await item.get_build():
        time.sleep(1)
    build = await item.get_build()
    async for line in build.progressive_output():
        print(line)

    print(await build.building)
    print(await build.result)

asyncio.run(main())
```

# Documentation
User Guide and API Reference is available on [Read the Docs](https://api4jenkins.readthedocs.io/)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/joelee2012/api4jenkins",
    "name": "api4jenkins",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "RESTAPI,Jenkins",
    "author": "Joe Lee",
    "author_email": "lj_2005@163.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/6c/7807330e834e24aabf7fd34eb3c3fc846a2dfe61e5ef026844d71bd28355/api4jenkins-2.0.3.tar.gz",
    "platform": null,
    "description": "[![Unit Test](https://github.com/joelee2012/api4jenkins/actions/workflows/unittest.yml/badge.svg?branch=main)](https://github.com/joelee2012/api4jenkins/actions/workflows/unittest.yml)\n[![Integration Test](https://github.com/joelee2012/api4jenkins/actions/workflows/integration.yml/badge.svg?branch=main)](https://github.com/joelee2012/api4jenkins/actions/workflows/integration.yml)\n![CodeQL](https://github.com/joelee2012/api4jenkins/workflows/CodeQL/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/joelee2012/api4jenkins/branch/main/graph/badge.svg?token=YGM4CIB149)](https://codecov.io/gh/joelee2012/api4jenkins)\n![PyPI](https://img.shields.io/pypi/v/api4jenkins)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/api4jenkins)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/api4jenkins)\n[![Documentation Status](https://readthedocs.org/projects/api4jenkins/badge/?version=latest)](https://api4jenkins.readthedocs.io/en/latest/?badge=latest)\n![GitHub](https://img.shields.io/github/license/joelee2012/api4jenkins)\n\n\n# Jenkins Python Client\n\n[Python3](https://www.python.org/) client library for [Jenkins API](https://www.jenkins.io/doc/book/using/remote-access-api/) which provides sync and async APIs.\n\n# Features\n\n- Provides sync and async APIs\n- Object oriented, each Jenkins item has corresponding class, easy to use and extend\n- Base on `api/json`, easy to query/filter attribute of item\n- Setup relationship between class just like Jenkins item\n- Support api for almost every Jenkins item\n- Pythonic\n- Test with latest Jenkins LTS\n\n# Installation\n\n```bash\npython3 -m pip install api4jenkins\n```\n\n# Quick start\n\nSync example:\n\n```python\n>>> from api4jenkins import Jenkins\n>>> client = Jenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))\n>>> client.version\n'2.176.2'\n>>> xml = \"\"\"<?xml version='1.1' encoding='UTF-8'?>\n... <project>\n...   <builders>\n...     <hudson.tasks.Shell>\n...       <command>echo $JENKINS_VERSION</command>\n...     </hudson.tasks.Shell>\n...   </builders>\n... </project>\"\"\"\n>>> client.create_job('path/to/job', xml)\n>>> import time\n>>> item = client.build_job('path/to/job')\n>>> while not item.get_build():\n...      time.sleep(1)\n>>> build = item.get_build()\n>>> for line in build.progressive_output():\n...     print(line)\n...\nStarted by user admin\nRunning as SYSTEM\nBuilding in workspace /var/jenkins_home/workspace/freestylejob\n[freestylejob] $ /bin/sh -xe /tmp/jenkins2989549474028065940.sh\n+ echo $JENKINS_VERSION\n2.176.2\nFinished: SUCCESS\n>>> build.building\nFalse\n>>> build.result\n'SUCCESS'\n```\n\nAsync example\n\n```python\nimport asyncio\nimport time\nfrom api4jenkins import AsyncJenkins\n\nasync main():\n    client = AsyncJenkins('http://127.0.0.1:8080/', auth=('admin', 'admin'))\n    print(await client.version)\n    xml = \"\"\"<?xml version='1.1' encoding='UTF-8'?>\n    <project>\n      <builders>\n        <hudson.tasks.Shell>\n          <command>echo $JENKINS_VERSION</command>\n        </hudson.tasks.Shell>\n      </builders>\n    </project>\"\"\"\n    await client.create_job('job', xml)\n    item = await client.build_job('job')\n    while not await item.get_build():\n        time.sleep(1)\n    build = await item.get_build()\n    async for line in build.progressive_output():\n        print(line)\n\n    print(await build.building)\n    print(await build.result)\n\nasyncio.run(main())\n```\n\n# Documentation\nUser Guide and API Reference is available on [Read the Docs](https://api4jenkins.readthedocs.io/)\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Jenkins Python Client",
    "version": "2.0.3",
    "project_urls": {
        "Documentation": "https://api4jenkins.readthedocs.io",
        "Homepage": "https://github.com/joelee2012/api4jenkins",
        "Source": "https://github.com/joelee2012/api4jenkins"
    },
    "split_keywords": [
        "restapi",
        "jenkins"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1197990f7e5c836db2ab86d6cd9eabd279a654b0966762bc47737840d8302f95",
                "md5": "e96456f48166b49322469b898a5e8a1f",
                "sha256": "8cd23678f077ba4df47eafe13866ae63db1a50ee29176f2d658564d042154aa0"
            },
            "downloads": -1,
            "filename": "api4jenkins-2.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e96456f48166b49322469b898a5e8a1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 29546,
            "upload_time": "2023-12-22T08:14:02",
            "upload_time_iso_8601": "2023-12-22T08:14:02.485766Z",
            "url": "https://files.pythonhosted.org/packages/11/97/990f7e5c836db2ab86d6cd9eabd279a654b0966762bc47737840d8302f95/api4jenkins-2.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d6c7807330e834e24aabf7fd34eb3c3fc846a2dfe61e5ef026844d71bd28355",
                "md5": "d4dc8b829729970bf4a8db4e49e71e84",
                "sha256": "f31bbeac48ef6d2c795c20cdca8ebafc34b8d92b09f1287c66484c42196bc514"
            },
            "downloads": -1,
            "filename": "api4jenkins-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "d4dc8b829729970bf4a8db4e49e71e84",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 24868,
            "upload_time": "2023-12-22T08:14:03",
            "upload_time_iso_8601": "2023-12-22T08:14:03.835462Z",
            "url": "https://files.pythonhosted.org/packages/9d/6c/7807330e834e24aabf7fd34eb3c3fc846a2dfe61e5ef026844d71bd28355/api4jenkins-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-22 08:14:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joelee2012",
    "github_project": "api4jenkins",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "api4jenkins"
}
        
Elapsed time: 0.18034s