To get a list of builds using the TravisCI API described here, it says that you need to put the repository ID in the request address.
I'm wondering, what is this ID, and where do I find it? Does it differ from the repository slug, which is username/reponame?
To determine the storage location of a repository, navigate to the repository in Bitbucket Server and select Settings. The location on disk will be displayed under Repository details. The numerical part of the path is the ID of the repository.
It is a discoverable and self-documenting RESTful API, and includes all the hypermedia features expected from a modern API. Our API can be used to automate many of your Travis CI build processes: get build info. get organization info. get nested resources.
Trigger Travis CI builds using the API V3 by sending a POST request to /repo/{slug|id}/requests : Get an API token from your Travis CI settings page. You'll need the token to authenticate most of these API requests.
The repository ID is the repo key which is shown in Travis CI API responses.
This can be either retrieve by:
$ curl -L http://api.travis-ci.org/repos/user_name/repo_name
or if you've travis
command installed, try:
$ travis show -r user_name/repo_name
Here is corresponding code in Ruby:
require 'travis'
repos = Travis::Repository.find_all(owner_name: 'user_name')
repos.each do |repo|
puts repo.slug
end
In above examples, change user_name
and repo_name
into the right values.
Reading through the TravisCI API, the repository ID is different from the slug. It is a number assigned to the repository by Travis and unrelated to the Github repository ID.
For example: curl https://api.travis-ci.org/repos/schwern/URI-Find
will return...
{
"id":527875,
"slug":"schwern/URI-Find",
"description":"Perl module to find URIs in arbitrary text",
"public_key":"...",
"last_build_id":29287626,
"last_build_number":"10",
"last_build_status":0,
"last_build_result":0,
"last_build_duration":28,
"last_build_language":null,
"last_build_started_at":"2014-07-07T03:43:28Z",
"last_build_finished_at":"2014-07-07T03:44:03Z"
}
You can use the id
to access the repository as well. curl https://api.travis-ci.org/repos/527875
will return the same thing.
As you can see with https://api.github.com/repos/schwern/URI-Find the Travis repository id differs from the Github repository id.
I assume the advantage of using the id vs the slug is the slug may change, repositories can be renamed and ownership transferred, but the id presumably will not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With