Yet another Python client for ThoughtWorks GOCD REST API.
Project description
Introduction
This project represent itself high level wrapper upon ThoughtWorks gocd REST API. Go Continuous Delivery is continues integration/deployment server, which helps you automate and streamline the build-test-release cycle for worry-free. Using this library you can access to internals of the Pipelines, check their statuses, download Artifacts and more.
Library has a Yagocd
class, which is a single entry point of whole project. Creating instance of it would give you
possibilities to work with all functionality.
Installation
$ pip install yagocd
Quick example
from yagocd import Yagocd
go = Yagocd(
server='https://example.com',
auth=('user', 'password'),
options={
'verify': False # skip verification for SSL certificates.
}
)
for pipeline in go.pipelines.list():
for instance in pipeline.history():
for stage in instance.stages():
for job in stage.jobs():
# print artifact urls for each job
for artifact in job.artifact.list():
for file_obj in artifact.files():
print(file_obj.data.url)
# print property of each job
for key, value in job.prop.list().items():
print "{} => {}".format(key, value)
Code Organisation
The code in the library organized as follows: the main entry point, that user should use is yagocd.client.Yagocd
class. Creating instance of it gives you access to all properties and actions gocd server provides.
This class contains list of managers, each of which is responsible for it’s particular area. Each manager could be
accessed as a property of Yagocd
class. Here is list of them:
agents
: manage build agentsconfigurations
: manage configurationfeeds
: work with feedsmaterials
: list,modify and notify materialspipelines
: work with pipelinesproperties
: work with job’s propertiesstages
: work with stagesusers
: manage users
Each of managers wraps REST API calls in functions. Depending on return value, it could be possible to get instance of
another class, that will provide additional functionality.
For example, yagocd.resources.pipeline.PipelineManager
manager could return instance of
yagocd.resources.pipeline.PipelineEntity
, which represents itself entity of specific pipeline and has
corresponding methods.
Development notes
Original API is part of the open source GOCD project. But it’s difficult to find appropriate implementation.
First, there are url rewrite rules in /server/webapp/WEB-INF/urlrewrite.xml in <!– RESTful URLS –> section.
Second, there is /server/webapp/WEB-INF/rails.new/config/routes.rb file, in which some routes are set as well.
Third, in /server/src/com/thoughtworks/go/server/controller folder there is implementation of all API endpoints, but with different interfaces and URLs (which are handled by aforementioned configs).
Using this information could give better understanding of internals of Go server for future development and support.
Running local server
As described in this post, there is ready to use Virtual Box image with pre-configured GoCD server and agent, which could easy development and debugging. To run, executing this command (ensure, that vagrant and Virtual Box are installed):
$ vagrant init gocd/gocd-demo
In the current directory will be created Vagrantfile
with initial content. I recommend forward ports:
config.vm.network "forwarded_port", guest: 8153, host: 8153
config.vm.network "forwarded_port", guest: 8154, host: 8154
One for http, another for https – this will make it possible to use it from https://localhost:8154/go/ url. After that run
$ vagrant up
and wait some time for machine to load and service to be up.
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
Built Distribution
Hashes for yagocd-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 245f9b5a75f1211ac009ebeb94ec28ca00739ffe16f1768c995c8e0d2113566e |
|
MD5 | 31b3ce030eab55810333ba016974ecf7 |
|
BLAKE2b-256 | 07f99e58a2a40077f053d23e45a8fb987fefa1b622dd7cab370fe4908f800bc5 |