Skip to content

Go library for accessing the Travis CI API V3

License

Notifications You must be signed in to change notification settings

robbybbb/go-travis

This branch is 10 commits ahead of shuheiktgw/go-travis:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6c95b2b · Oct 27, 2022
Sep 19, 2018
Apr 25, 2020
Apr 26, 2020
Jul 4, 2019
Apr 29, 2020
Feb 16, 2016
Sep 15, 2018
Jul 6, 2019
Apr 29, 2020
May 30, 2019
May 2, 2019
Apr 26, 2020
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 31, 2019
May 5, 2019
May 30, 2019
May 2, 2019
May 5, 2019
Oct 27, 2022
Apr 26, 2020
Apr 26, 2020
May 30, 2019
Sep 28, 2018
May 5, 2019
May 5, 2019
Aug 17, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
Sep 28, 2018
Sep 28, 2018
Aug 7, 2019
Aug 7, 2019
Aug 7, 2019
Oct 25, 2022
Jul 4, 2019
Apr 26, 2020
May 2, 2019
May 5, 2019
May 30, 2019
Oct 27, 2022
Aug 17, 2019
May 5, 2019
May 30, 2019
May 18, 2019
May 17, 2019
May 30, 2019
Oct 2, 2018
May 5, 2019
May 30, 2019
May 2, 2019
May 5, 2019
May 30, 2019
May 3, 2019
May 5, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 31, 2019
May 5, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 31, 2019
May 5, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
May 5, 2019
May 5, 2019
May 30, 2019
Apr 21, 2019
May 5, 2019
May 5, 2019
Sep 29, 2018
Oct 27, 2022
Apr 29, 2020
May 30, 2019
May 5, 2019
May 5, 2019
Apr 29, 2020

Repository files navigation

go-travis

GitHub release Actions Status License GoDoc

go-travis is a Go client library to interact with the Travis CI API V3.

Installation

$ go get github.com/shuheiktgw/go-travis

Usage

Interaction with the Travis CI API is done through a Client instance.

import "github.com/shuheiktgw/go-travis"

client := travis.NewClient(travis.ApiOrgUrl, "TravisApiToken")

// List all the builds which belongs to the current user
builds, res, err := client.Builds.List(context.Background(), nil)

URL

Currently, there are two possible options for Travis CI API URL.

  • https://api.travis-ci.org/
  • https://api.travis-ci.com/

You should know which URL your project belongs to, and hand it in to NewClient method as an argument. We provide two constants, ApiOrgUrl for https://api.travis-ci.org/ and ApiComUrl for https://api.travis-ci.com/, so please choose one of them.

Travis CI is migrating projects in https://api.travis-ci.org/ to https://api.travis-ci.com/, and please visit their documentation page for more information on the migration.

Authentication

client := travis.NewClient(travis.ApiOrgUrl, "TravisApiToken")

// Jobs.Cancel will success
_, _, err := client.Jobs.Cancel(context.Background(), 12345)

You can issue Travis API token and hand it in to NewClient method directly. You can issue your token by visiting your Travis CI Profile page or using Travis CI command line tool.

For more information on how to issue Travis CI API token, please visit their documentation.

Unauthenticated client

It is possible to interact with the API without authentication. However, most resources are not accessible.

client := travis.NewClient(travis.ApiOrgUrl, "")

// Builds.ListByRepoSlug is available without authentication
builds, resp, err := client.Builds.ListByRepoSlug(context.Background(), "shuheiktgw/go-travis", nil)

// Jobs.Cancel is unavailable without authentication
_, _, err = client.Jobs.Cancel(context.Background(), 12345)

Standard Representation / Minimal Representation

Travis CI API V3 provides two types of resource representations, standard and minimal. The API returns the resource you request in a standard representation and the resources related to the original resource in a minimal representation.

If you want the related resources in a standard representation, you need to eager load them by specifying include option.

For example, to eager load repository and commits when fetching a build, one can specify Include in BuildOption:

opt := BuildOption{Include: []string{"build.repository", "build.commits"}}
build, _, err := client.Builds.Find(context.Background(), 123, &opt)

Contribution

Contributions are of course always welcome!

  1. Fork shuheiktgw/go-travis (https://github.com/shuheiktgw/go-travis/fork)
  2. Run make install to install dependencies
  3. Create a feature branch
  4. Commit your changes
  5. Run test using make test
  6. Create a Pull Request

See CONTRIBUTING.md for details.

Acknowledgements

This library is originally forked from Ableton/go-travis and most of the credits of this library is attributed to them.

About

Go library for accessing the Travis CI API V3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Other 0.2%