Giter Site home page Giter Site logo

drone-python's Introduction

drone-python Build Status

Python client for the Drone CI public remote api built using the popular python requests library.

Installation

  • Using Python package manager (pip)

    $ pip install drone-python
  • From source
    Ensure you have a working installation of Python 3.x on your system.
    Clone the repository and run the setup script provided.

    $ git clone [email protected]:tinvaan/drone-python.git
    $ cd drone-python
    $ python setup.py install

Environment

Ensure you have the DRONE_TOKEN and optionally, the DRONE_SERVER environment variables setup correctly.

$ export DRONE_SERVER="https://cloud.drone.io"
$ export DRONE_TOKEN="<your Drone CI access token>

Usage examples

Fetch all linked repos

>>> from drone import drone
>>> client = drone('tinvaan', 'packager')
>>> client.repos.all()
[{'id': 799963,
  'uid': '45485693',
  'user_id': 0,
  'namespace': 'tinvaan',
  'name': 'Algorithms',
  'slug': 'tinvaan/Algorithms',
    ...
    ...
  'version': 1},

    ...
    ...
    ...

 {'id': 7993143,
  'uid': '1897133997',
  'user_id': 0,
  'namespace': 'tinvaan',
  'name': 'zeit-logdna',
  'slug': 'tinvaan/zeit-logdna',
    ...
    ...
  'version': 1}]

Add a new secret

>>> secret = {
        'name': 'testsecret',
        'data': 'mysecretvalue',
        'pull_request': False
   }
>>> client.secret.create(**secret)
{'id': 55114, 'repo_id': 7134978, 'name': 'testsecret'}

Fetch all builds for a repository

>>> client.build.all()
[{'id': 342416, ... 'version': 3},
 {'id': 342400, ... 'version': 3},
 {'id': 341144, ... 'version': 3}]

Contribute

If you notice any issues, bugs or missing features in this project, please feel free to open tickets(github issues) or pull requests for the same.

If you would like to contribute code, check out the open issues and if you need help getting started, shoot a mail to [email protected]

drone-python's People

Contributors

tinvaan avatar wolverine-14 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

drone-python's Issues

Documentation

Need some work to generate documentation for modules and functions exposed within them.

LICENSE file

This project is free in every sense. What's a good license we could use for this ?

You don't need to alter the `requests.patch` calling semantics based on whether your method was passed `params` or `data` content

https://github.com/tinvaan/PyDroneio/blob/d89d042e6938685e341e15014ef379604a4670e8/drone/http.py#L20

You don't need to check params and data like you're doing here and change the calling semantics for request.post(). You can simplify all of this down to:

    r = requests.patch(url, headers=headers, params=params, data=data)
    if not r.ok:
        r.raise_for_status()
    return r.json()

This applies to all the methods you have in this class that call requests methods like this (patch and get).

Drone upstream issue with builds

Just did some debugging to conclude that drone incorrectly reports the build status and is unable to restart existing builds in some cases.

Eg:

▶ drone build info tinvaan/drone-test-ci 46
Number: 46
Status: killed
Event: push
Commit: a4bed7d39ba5cdb85e6dd9dd20d7bf33f440c70b
Branch: master
Ref: refs/heads/master
Author: tinvaan <[email protected]>
Message: Initial commit

▶ drone build restart tinvaan/drone-test-ci 46
client error 500: {"message":"Not Found"}

This causes our CI pipeline to fail. The workaround for this would be to mock out responses from the drone API #TODO

Nowhere mentioned you have to set DRONE_TOKEN and DRONE_SERVER in Readme.md

It is nowhere mentioned you have to set DRONE_TOKEN and DRONE_SERVER in Readme.md in the example section. But without them it does not work. So this should be mentioned.

Anyway thanks for publishing, since I need exactly your library to try to solve my problem of depended build triggering from a running pipeline over the api.

So thank you and keep your good work up2date.

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.