Roz King
Pronouns: they, them, theirs
I am a graduate of UC Davis with a B.S. degree in psychology and statistics. I’ve worked conducting data analysis and building data systems in fields as diverse as Healthcare, Agriculture, Education, and Genomics. In the past I’ve been a Data Scientist, a DBA, a DevOps Engineer, a Researcher, a Software Developer, and a Linux Systems Admin, but I find I operate best when I blur the lines between all those roles. I’m deeply devoted to utilizing data for social good, and strive to work with like minded people.
I’m passionate about social and economic justice, open access to information, and using technological advancements in data collection, management, and analysis, to create measurable positive change.
My resume offers more information on my educational and vocational history. My website shows the services I offer as a consultant and has a blog detailing a few recent projects, and my embarrassingly candid blog fauxktrends offers a view into a web scraping and analysis project I found engaging several years ago. I link to it not because it is terribly impressive or engaging, but to remind myself that the past informs the future, and forgetting about the past (purposefully or not), means we will be doomed to repeat it*.
*An issue that comes up often in building models, mathematical or otherwise, as it is so easy and can be so damaging to encode historical biases in our models.
I play drums in an instrumental jazz/rock/funk band called The Splodeyheads, one of my life goals is to get a private pilot license, and I’m always looking to grow my collection of strange taxidermy.
Regrettably, many of the projects I’ve worked on that I am most proud of live behind closed doors, due to the sensitivity of the data I work with and employer policies. What follows are some projects I’ve worked on that I can show off. Many are hobbies entirely unrelated to my substantive interests, but a few gems offer some real value.
I designed Agroft with support and funding from USAID and the UC Davis International Programs Office. Agroft is a graphical interface to R that is designed to help lower the R learning curve for agricultural researchers and make sound statistical analysis of field trial experimental designs accessible to anyone who needs it.
The GUI offers the user a logical workflow that progresses through loading data, specifying experimental design, checking the assumptions of the model(s) required for that design, data transformations, running a model and posthoc tests, plotting the data, and exporting results into a useful report, with helpful tool tips and guidance on terms and statistical procedures along the way. The user doesn’t need to know about the complexity of the models behind the scenes, but they are shown the code that is run along the way and encouraged to build on that code on their own.
Errorizer
is a R package I wrote and submitted to CRAN to help me debug code that executes in large iterations and fails due to unhandled errors. Its only function, errorize
, takes a function as one of its arguments and returns that same function with expanded error handling abilities, including the ability to write debugging info and data structures to disk on error. It was particularly useful when processing the hundreds of thousands of web pages I scraped for my social media analysis–an unhandled error 2 hours into my script can be difficult to debug post hoc with just the stack trace, so “errorizing” my processing function allowed me to go back and interactively debug the error after my script had finished.
I wrote a short blog series on my website about a problem I encounted a few years ago that could have been addressed with deep learning techniques. I simulated some similar data and showed how to build a model that can address that problem successfully.
I spent some time scraping a popular dating site in an attempt to practice extracting info from diverse samples and to increase my skills in interactive data visualization, text mining and web-scraping. Below are links to notebooks that show my scraping and munging process, as well as a few analyses I’ve done.
http://doi.org/10.1007/s10803-014-2202-y


Chocolate
问题描述 :
“Green, orange, brown, red…”, colorful sugar-coated shell maybe is the most attractive feature of ACM chocolate. How many colors have you ever seen? Nowadays, it’s said that the ACM chooses from a palette of twenty-four colors to paint their delicious candy bits.
 Each time he took one chocolate from the package and placed it on the table. If there were two chocolates of the same color on the table, he ate both of them. He found a quite interesting thing that in most of the time there were always 2 or 3 chocolates on the table.
Now, here comes the problem, if there are C colors of ACM chocolates in the package (colors are distributed evenly), after N chocolates are taken from the package, what’s the probability that there is exactly M chocolates on the table? Would you please write a program to figure it out?
输入:
For each case, there are three non-negative integers: C (C <= 100), N and M (N, M <= 1000000).
The input is terminated by a line containing a single zero.
输出:
样例输入:
5 100 2 0
样例输出:
0.625
解题代码:
//* @author: import java.util.*; public class Main{ public static void main(String args[]){ Scanner in=new Scanner(System.in); while(true){ int c=in.nextInt(); if(c==0) break; int n=in.nextInt(); int m=in.nextInt(); double arr[][]=new double[1002][101]; if (m>c||m>n){ System.out.printf("0.000\n"); continue; } if (n>1000) { if ((n%2)!=0) n = 1001; else n = 1000; } arr[0][0] = 1; for (int i=1;i<=n;++i){ arr[i][1] += arr[i-1][0]; arr[i][c-1] += arr[i-1][c]; for (int j = 1 ; j < c ; j++){ arr[i][j-1] += arr[i-1][j] * j / c; arr[i][j+1] += arr[i-1][j] * (c-j) / c; } } System.out.printf("%.3f\n",arr[n][m]); } } }
很高兴你会喜欢这个网站。目前还没有一个开发团队，网站是我一个人在维护，都是用的开源系统，也没有太多需要开发的部分，主要是内容整理。非常感谢你的关注。
此时的数据量还是很小的，耗时却不短。这种方法确实可以，当然或许还有其他的优化方案，但是优化只能针对某些数据，不太可能在所有情况下都能在可接受的时间内求解出答案。
代码过于复杂了吧
额楼主能否在发布代码的同时对解题思路做个讲解呢？这样大家在学习的时候就方便多了。
给力，赞一个
很好的思路，可以借鉴
第15行代码，/n/n，应该改为nn
Java真是解决大数的利器
这个系列很不错
第一题是不是可以这样想，生了n孩子的家庭等价于n个家庭各生了一个1个孩子，这样最后男女的比例还是1:1
算法，他认识我，我不认识他，后来有人告诉我你写的这段代码就是XXX算法。。。
位运算真赞
很好，注释很详细啊
还是有些难度的！


%= circled_title(3, "Upload stemcell") %>
A Stemcell is an operating system image that BOSH uses to create VMs. Official BOSH stemcells are maintained with security updates at bosh.io.
Upload stemcell to Director.
$ wget --content-disposition https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-trusty-go_agent
$ bosh upload stemcell bosh-stemcell-3147-warden-boshlite-ubuntu-trusty-go_agent.tgz
See uploaded stemcells:
$ bosh stemcells
Acting as user 'admin' on 'Bosh Lite Director'
+---------------------------------------------+---------+
| Name | Version |
+---------------------------------------------+---------+
| bosh-warden-boshlite-ubuntu-trusty-go_agent | 3147 |
+---------------------------------------------+---------+
(*) Currently in-use
Stemcells total: 1
Learn more:


We are continuing to work through the repercussions of the php.net malware issue described in a news post earlier today. As part of this, the php.net systems team have audited every server operated by php.net, and have found that two servers were compromised: the server which hosted the www.php.net, static.php.net and git.php.net domains, and was previously suspected based on the JavaScript malware, and the server hosting bugs.php.net. The method by which these servers were compromised is unknown at this time.
All affected services have been migrated off those servers. We have verified that our Git repository was not compromised, and it remains in read only mode as services are brought back up in full.
As it's possible that the attackers may have accessed the private key of the php.net SSL certificate, we have revoked it immediately. We are in the process of getting a new certificate, and expect to restore access to php.net sites that require SSL (including bugs.php.net and wiki.php.net) in the next few hours.
To summarise, the situation right now is that:
- JavaScript malware was served to a small percentage of php.net users from the 22nd to the 24th of October 2013.
- Neither the source tarball downloads nor the Git repository were modified or compromised.
- Two php.net servers were compromised, and have been removed from service. All services have been migrated to new, secure servers.
- SSL access to php.net Web sites is temporarily unavailable until a new SSL certificate is issued and installed on the servers that need it.
Over the next few days, we will be taking further action:
- php.net users will have their passwords reset. Note that users of PHP are unaffected by this: this is solely for people committing code to projects hosted on svn.php.net or git.php.net.
We will provide a full post mortem in due course, most likely next week. You can also get updates from the official php.net Twitter: @official_php.


Registers a transformation function to be executed if this future completes with any
Outcome
(i.e., no run-aborting exception is thrown), returning
a new FutureOutcome
representing the result of passing
this FutureOutcome
's Outcome
result to the given transformation function.
Registers a transformation function to be executed if this future completes with any
Outcome
(i.e., no run-aborting exception is thrown), returning
a new FutureOutcome
representing the result of passing
this FutureOutcome
's Outcome
result to the given transformation function.
If the passed function completes abruptly with an exception, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a transformation function to execute if and when this FutureOutcome
completes with an Outcome
an execution context that provides a strategy for executing the transformation function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with a valid
Outcome
, the passed callback function has completed execution.
Indicates whether this FutureOutcome
has completed.
Indicates whether this FutureOutcome
has completed.
This method does not block.
true
if this FutureOutcome
has completed; false
otherwise.
Registers a callback function to be executed if this future completes because a run-aborting exception was thrown, returning a new future that completes only after the callback has finished execution.
Registers a callback function to be executed if this future completes because a run-aborting exception was thrown, returning a new future that completes only after the callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with an abort.
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes abnormally with
a run-aborting exception, the passed callback function has completed execution.
Registers a callback function to be executed if this future completes with
Canceled
, returning a new future that completes only after the
callback has finished execution.
Registers a callback function to be executed if this future completes with
Canceled
, returning a new future that completes only after the
callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with Canceled
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with Canceled
, the
passed callback function has completed execution.
Registers a callback function to be executed after this future completes, returning a new future that completes only after the callback has finished execution.
Registers a callback function to be executed after this future completes, returning a new future that completes only after the callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute when this FutureOutcome
completes
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
and, subsequently, the passed callback function have completed execution.
Registers a callback function to be executed if this future completes with
Failed
, returning a new future that completes only after the
callback has finished execution.
Registers a callback function to be executed if this future completes with
Failed
, returning a new future that completes only after the
callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with Failed
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with Failed
, the
passed callback function has completed execution.
Registers a callback function to be executed if this future completes with any
Outcome
(i.e., no run-aborting exception is thrown), returning
a new future that completes only after the callback has finished execution.
Registers a callback function to be executed if this future completes with any
Outcome
(i.e., no run-aborting exception is thrown), returning
a new future that completes only after the callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with an Outcome
(i.e., not an abort)
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with a valid
Outcome
, the passed callback function has completed execution.
Registers a callback function to be executed if this future completes with
Pending
, returning a new future that completes only after the
callback has finished execution.
Registers a callback function to be executed if this future completes with
Pending
, returning a new future that completes only after the
callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with Pending
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with Pending
, the
passed callback function has completed execution.
Registers a callback function to be executed if this future completes with
Succeeded
, returning a new future that completes only after the
callback has finished execution.
Registers a callback function to be executed if this future completes with
Succeeded
, returning a new future that completes only after the
callback has finished execution.
The resulting FutureOutcome
will have the same result as this FutureOutcome
, unless
the callback completes abruptly with an exception. In that case, the resulting FutureOutcome
will be determined by the type of the thrown exception:
TestPendingException
- Good(Pending)
TestCanceledException
- Good(Canceled(<the exception>))
Throwable
- Good(Failed(<the exception>))
Throwable
- Bad(<the run-aborting exception>)
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a side-effecting function to execute if and when this FutureOutcome
completes with Succeeded
an execution context that provides a strategy for executing the callback function
a new FutureOutcome
that will complete only after this FutureOutcome
has completed and, if this FutureOutcome
completes with Succeeded
, the
passed callback function has completed execution.
Converts this FutureOutcome
to a Future[Outcome]
.
Converts this FutureOutcome
to a Future[Outcome]
.
the underlying Future[Outcome]
Returns a value that indicates whether this FutureOutcome
has completed,
and if so, indicates its result.
Returns a value that indicates whether this FutureOutcome
has completed,
and if so, indicates its result.
If this FutureOutcome
has not yet completed, this method will return
None
. Otherwise, this method will return a Some
that contains
either a Good[Outcome]
, if this FutureOutcome
completed with
a valid Outcome
result, or if it completed with a thrown run-aborting
exception, a Bad[Throwable]
.
For more information on run-aborting exceptions, see the Run-aborting exceptions section
in the main Scaladoc for trait Suite
.
a Some
containing an Or
value that indicates the result of this
FutureOutcome
if it has completed; None
otherwise.
Wrapper class for
Future[Outcome]
that presents a more convenient API for manipulation inwithFixture
methods in async styles.This type serves as the result type of both test functions and
withFixture
methods in ScalaTest's async styles. AFuture[Outcome]
is not used as this result type for two reasons. First,Outcome
treats exceptions specially, and as a result methods onFuture
would usually not yield the desiredFuture[Outcome]
result. Only run-aborting exceptions should result in a failedFuture[Outcome]
. Any other thrown exception other thanTestCanceledException
orTestPendingException
should result in a successfulFuture
containing aorg.scalatest.Failed
. A thrownTestCanceledException
should result in a successfulFuture
containing anorg.scalatest.Canceled
; A thrownTestPendingException
should result in a successfulFuture
containing aorg.scalatest.Pending
. If manipulating aFuture[Outcome]
directly, by contrast, any thrown exception would result in a failedFuture
.Additionally, to be consistent with corresponding transformations in traditional testing styles, methods registering callbacks should return a new future outcome that doesn't complete until both the original future outcome has completed and the subsequent callback has completed execution. Additionally, if the callback itself throws an exception, that exception should determine the result of the future outcome returned by the callback registration method. This behavior is rather inconvenient to obtain on the current
Future
API, soFutureOutcome
provides well-named methods that have this behavior.Lastly, the
FutureOutcome
is intended to help prevent confusion by eliminating the need to work with types likescala.util.Success(org.scalatest.Failed)
. For this purpose aorg.scalactic.Or
is used instead of ascala.util.Try
to describe results ofFutureOutcome
.A
FutureOutcome
represents a computation that can result in anOutcome
or an "abort." An abort means that a run-aborting exception occurred during the computation. Any other, non-run-aborting exception will be represented as an non-Succeeded
Outcome
: one ofFailed
,Canceled
, orPending
.The methods of
FutureOutcome
include the following callback registration methods:onSucceededThen
- registers a callback to be executed if the future outcome isSucceeded
.onFailedThen
- registers a callback to be executed if the future outcome isFailed
.onCanceledThen
- registers a callback to be executed if the future outcome isCanceled
.onPendingThen
- registers a callback to be executed if the future outcome isPending
.onOutcomeThen
- registers a callback to be executed if the future outcome is actually anOutcome
and not an abort.onAbortedThen
- registers a callback to be executed if the future outcome aborts.onCompletedThen
- registers a callback to be executed upon completion no matter how the future outcome completes.The callback methods listed previously can be used to perform a side effect once a
FutureOutcome
completes. To change anOutcome
into a differentOutcome
asynchronously, use thechange
registration method, which takes a function fromOutcome
toOutcome
. The other methods onFutureOutcome
,isCompleted
andvalue
, allow you to poll aFutureOutcome
. None of the methods onFutureOutcome
block. Lastly, because an implicitFuturistic
instance is provided forFutureOutcome
, you can usecomplete
-lastly
syntax withFutureOutcome
.


Start Bootstrap can help you build better websites using the Bootstrap CSS framework! Just download your template and start going, no strings attached!
Find Out MoreOur templates are updated regularly so they don't break.
You can use this theme as is, or you can make changes!
We update dependencies to keep things fresh.
You have to make your websites with love these days!
Our templates are updated regularly so they don't break.
You can use this theme as is, or you can make changes!
We update dependencies to keep things fresh.
You have to make your websites with love these days!
Ready to start your next project with us? That's great! Give us a call or send us an email and we will get back to you as soon as possible!


Badge creator
Use Flickriver Badge Creator to create a badge linking to your photos, your group or any other Flickriver view.
You can place your badge on your Flickr profile, Blog or Website.
Add to your iGoogle or Netvibes page
Flickriver widget for iGoogle or Netvibes can display almost any Flickriver view - most interesting today, by user, by group, by tag etc. Once added to your personalized homepage, just edit widget settings to select your desired view.
Clickr on one of the buttons below to install:
"View on Flickriver" Greasemonkey script
A Greasemonkey script that adds Flickriver links to various Flickr photo pages - user photos, favorites, pools etc, allowing to quickly open the corresponding Flickriver view.
Also, allows quickly viewing any Flickr photo on black background in large size.
Install "View on Flickriver" script
Bookmarklet
While viewing any Flickr photos page, click on the bookmarklet to open the same view on Flickriver.
To install: drag and drop the following link to your Bookmarks toolbar.
IE users - add the link to your Favorites under the Links folder


Overview
GET / HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
GET / HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token "YOUR TRAVIS ACCESS TOKEN" Host: api.travis-ci.com
GET /api HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token "YOUR TRAVIS ACCESS TOKEN" Host: travis.example.com
$ travis raw / {"hello"=>"world"} $ travis raw / --pro {"hello"=>"world"} $ travis raw / --api-endpoint https://travis.example.com/api {"hello"=>"world"}
require 'travis' # talk to travis-ci.org via client object client = Travis::Client.new repository = client.repo('travis-ci/travis.rb') # talk to travis-ci.org via Travis namespace repository = Travis::Repository.find('travis-ci/travis.rb') # talk to travis-ci.com via client object client = Travis::Client.new('https://api.travis-ci.com') client.access_token = 'YOUR TRAVIS ACCESS TOKEN' repository = client.repo('travis-pro/billing') # talk to travis-ci.com via Travis::Pro namespace Travis::Pro.access_token = 'YOUR TRAVIS ACCESS TOKEN' repository = Travis::Pro::Repository.find('travis-pro/billing') # talk to travis.example.com via client object client = Travis::Client.new('https://travis.example.com/api') client.access_token = 'YOUR TRAVIS ACCESS TOKEN' repository = client.repo('my/repo') # talk to travis.example.com via custom namespace My = Travis::Client::Namespaces.new('https://travis.example.com/api') My.access_token = 'YOUR TRAVIS ACCESS TOKEN' My::Repository.find('my/repo')
Welcome to the Travis CI API documentation. This is the API used by the official Travis CI web interface, so everything the web ui is able to do can also be accomplished via the API.
The first thing you will have to find out is the correct API endpoint to use.
- Travis CI for open source: For open source projects tested on travis-ci.org, use https://api.travis-ci.org.
- Travis Pro: For private projects tested on travis-ci.com, use https://api.travis-ci.com.
- Travis Enterprise: For projects running on a custom setup, use https://travis.example.com/api (where you replace travis.example.com with the domain Travis CI is running on).
Note that both Pro and Enterprise will require almost all API calls to be authenticated.
Making Requests
GET / HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json {"hello":"world"}
$ travis raw / {"hello":"world"}
require 'travis' # You usually don't want to fire API requests manually client = Travis::Client.new client.get_raw('/') # => {"hello"=>"world"} client.get('/repos/sinatra/sinatra') # => {"repo"=>#<Travis::Client::Repository: sinatra/sinatra>}
When you write your own Travis CI client, please keep the following in mind:
- Always set the User-Agent header. This header is not required right now, but will be in the near future. Assuming your client is called “My Client”, and it’s current version is 1.0.0, a good value would be
MyClient/1.0.0
. For our command line client running on OS X 10.9 on Ruby 2.1.1, it might look like this:Travis/1.6.8 (Mac OS X 10.9.2 like Darwin; Ruby 2.1.1; RubyGems 2.0.14) Faraday/0.8.9 Typhoeus/0.6.7
. - Always set the Accept header to
application/vnd.travis-ci.2+json
.
Any existing client library should take care of these for you.
External APIs
GET /config HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "config": { "host": "travis-ci.org", "pusher": { "key": "5df8ac576dcccf4fd076" }, "github": { "api_url": "https://api.github.com", "scopes": [ "read:org", "user:email", "repo_deployment", "repo:status", "write:repo_hook" ] } } }
$ travis raw /config {"config"=> {"host"=>"travis-ci.org", "pusher"=>{"key"=>"5df8ac576dcccf4fd076"}, "github"=> {"api_url"=>"https://api.github.com", "scopes"=> ["read:org", "user:email", "repo_deployment", "repo:status", "write:repo_hook"]}}}
require 'travis' client = Travis::Client.new client.config # => {"host"=>"travis-ci.org", # "pusher"=>{"key"=>"5df8ac576dcccf4fd076"}, # "github"=> # {"api_url"=>"https://api.github.com", # "scopes"=> # ["read:org", # "user:email", # "repo_deployment", # "repo:status", # "write:repo_hook"]}}
Travis CI integrates with external services, some of which your client library might want to interface with directly. Most prominently, it uses GitHub as source for users, organizations and repositories, and Pusher for live streaming logs.
You can ask the API for the connection details to these services by loading the config
endpoint.
This includes, amongst other things:
- The GitHub API endpoint (this might be a GitHub enterprise endpoint) and the GitHub scopes currently required by Travis CI. These are the scopes you should use when generating a temporary GitHub token for authentication.
- The Pusher application key. If the setup is running behind a firewall and uses Slanger, it will also include the Slanger URL.
Authentication
GET /users HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org Authorization: token "YOUR TRAVIS ACCESS TOKEN"
$ travis whoami -t "YOUR TRAVIS ACCESS TOKEN"
require 'travis' # against the Travis namespace Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' Travis::User.current # against a client object client = Travis::Client.new(access_token: 'YOUR TRAVIS ACCESS TOKEN') client.user
To authenticate against Travis CI, you need an API access token.
You can retrieve a token by using a GitHub token to prove who you are. In the future, we are planning to add a proper OAuth handshake for third party applications.
With a GitHub token
POST /auth/github HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org Content-Type: application/json Content-Length: 37 {"github_token":"YOUR GITHUB TOKEN"}
HTTP/1.1 200 OK Content-Type: application/json {"access_token":"YOUR TRAVIS ACCESS TOKEN"}
$ travis login --github-token "YOUR GITHUB TOKEN" Successfully logged in! $ travis token Your access token is YOUR TRAVIS ACCESS TOKEN
require 'travis' # against the Travis namespace Travis.github_auth(token) # against a client object client = Travis::Client.new client.github_auth(token)
If you have a GitHub token, you can use the GitHub authentication endpoint to exchange it for an access token. The Travis API server will not store the token or use it for anything else then verifying the user account.
Note that therefore the API cannot be used to create new user accounts. The user will have to log in at least once via the web interface before interfacing with the API by other means.
Creating a temporary GitHub token
POST /authorizations HTTP/1.1 Host: api.github.com Content-Type: application/json Authorization: Basic ... { "scopes": [ "read:org", "user:email", "repo_deployment", "repo:status", "write:repo_hook" ], "note": "temporary token to auth against travis" }
HTTP/1.1 201 Created Content-Type: application/json { "id": 1, "url": "https://api.github.com/authorizations/1", "scopes": [ "read:org", "user:email", "repo_deployment", "repo:status", "write:repo_hook" ], "token": "YOUR GITHUB TOKEN", "note": "temporary token to auth against travis" }
POST /auth/github HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org Content-Type: application/json Content-Length: 37 {"github_token":"YOUR GITHUB TOKEN"}
HTTP/1.1 200 OK Content-Type: application/json {"access_token":"YOUR TRAVIS ACCESS TOKEN"}
DELETE /authorizations/1 HTTP/1.1 Host: api.github.com Authorization: Basic ...
$ travis login --auto Successfully logged in! $ travis token Your access token is YOUR TRAVIS ACCESS TOKEN
require 'travis' require 'travis/tools/github' # drop_token will make the token a temporary one github = Travis::Tools::Github.new(drop_token: true) do |g| g.ask_login = -> { print("GitHub login: "); gets } g.ask_password = -> { print("Password: "); gets } g.ask_otp = -> { print("Two-factor token: "); gets } end github.with_token do |token| Travis.github_auth(token) end Travis.access_token # => "YOUR TRAVIS ACCESS TOKEN"
Since Travis CI will not store the GitHub token handed to it for authentication, it is possible to generate a temporary GitHub token and remove it again after the authentication handshake.
To create and delete the GitHub token, you can either use the GitHub web interface or automate it via the GitHub API.
Make sure your GitHub token has the scopes required by Travis CI.
If you automate this process, authentication will become a handshake consisting of three requests:
- Create a GitHub token via the GitHub API, store GitHub token and URL.
- Use the
/auth/github
endpoint to exchange it for an access token. Store the access token. - Delete the GitHub token via the GitHub API.
Some client libraries will automate this handshake for you.
GitHub OAuth handshake
Triggering an OAuth handshake between GitHub and Travis CI:
log in
Running the OAuth handshake in an iframe:

You can also trigger a full OAuth handshake between Travis CI and GitHub by opening /auth/handshake
in a web browser. The endpoint takes an optional redirect_uri
query parameter, which takes a URL the web browser will end up on if the handshake is successful.
There is an alternative version of this that will try to run the handshake in a hidden iframe and using window.postMessage
to hand the token to the website embedding the iframe. This endpoint will only work for whitelisted websites.
Entities
Accounts
GET /accounts HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org Authorization: token "YOUR TRAVIS ACCESS TOKEN"
HTTP/1.1 200 OK Content-Type: application/json { "accounts" : [ { "repos_count" : 167, "name" : "Konstantin Haase", "type" : "user", "id" : 267, "login" : "rkh" }, { "repos_count" : 70, "name" : "Travis CI", "type" : "organization", "id" : 87, "login" : "travis-ci" } ] }
$ travis accounts rkh (Konstantin Haase): subscribed, 167 repositories travis-ci (Travis CI): subscribed, 70 repositories
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' Travis.accounts.each do |account| puts "#{account.login} has #{account.repos_count}" end
A user might have access to multiple accounts. This is usually the account corresponding to the user directly and one account per GitHub organization.
Attributes
| Attribute | Description |
|---|---|
| id | user or organization id |
| name | account name on GitHub |
| login | account login on GitHub |
| type | user or organization |
| repos_count | number of repositories |
| subscribed | whether or not the account has a valid subscription |
The subscribed
attribute is only available on Travis Pro.
List accounts
GET /accounts
| Parameter | Default | Description |
|---|---|---|
| all | false | whether or not to include accounts the user does not have admin access to |
This request always needs to be authenticated.
Annotations
GET /jobs/42/annotations HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "annotations" : [ { "id" : 1, "job_id" : 42, "description" : "foo bar", "url" : "http://example.com/job-42", "status" : "passed" } ] }
$ travis show # job info will include annotations
require 'travis' job = Travis::Job.find(42) job.annotations.each do |annotation| puts annotation.description end
Attributes
| Attribute | Description |
|---|---|
| id | annotation id |
| job_id | job id the annotation is for |
| description | textual description of the annotation |
| url | url with more information |
| status | annotation status |
List Annotations
GET /jobs/{job.id}/annotations
Create Annotation
POST /jobs/{job.id}/annotations
| Parameter | Default | Description |
|---|---|---|
| username | user name for provider authentication | |
| key | secret key for provider authentication | |
| description | textual description of the annotation | |
| url | url with more information | |
| status | annotation status |
Branches
GET /repos/rails/rails/branches HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "branches": [ { "id": 22554234, "repository_id": 891, "commit_id": 6534402, "number": "15184", "config": {}, "state": "created", "started_at": "2014-04-08T00:17:34Z", "finished_at": "2014-04-08T00:48:59Z", "duration": 30546, "job_ids": [], "pull_request": false } ] }
$ travis branches -r rails/rails v4.1.0: #15184 created Dont encourage aliases now that … master: #15183 created Dont abbreviate that which needs… 4-1-0: #15183 created Dont encourage aliases now that … 4-1-stable: #15185 created Merge branch '4-1-0' into 4-1-st… adequaterecord: #15158 passed wrap the literal value before ha…
require 'travis' repository = Travis::Repository.find('rails/rails') repository.branches # => {"v4.1.0" => #<Travis::Client::Build: rails/rails#15184>, # "master" => #<Travis::Client::Build: rails/rails#15183>, # "4-1-0" => #<Travis::Client::Build: rails/rails#15183>, # "4-1-stable" => #<Travis::Client::Build: rails/rails#15185>, # "adequaterecord" => #<Travis::Client::Build: rails/rails#15158>, # "4-0-stable" => #<Travis::Client::Build: rails/rails#15143>}
The branches API can be used to get information about the latest build on a given branch.
Attributes
See builds.
List Branches
This will list the latest 25 branches.
 } ] }
$ travis raw /broadcasts {"broadcasts"=>[{"id"=>451, "message"=>"This is a broadcast!"}]}
require 'travis' Travis::Broadcast.current.each do |broadcast| puts broadcast.message end
Attributes
| Attribute | Description |
|---|---|
| id | broadcast id |
| message | broadcast message |
List Broadcasts
GET /broadcasts
This request always needs to be authenticated.
Builds
GET /repos/sinatra/sinatra/builds HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "builds": [ { "commit_id": 6534711, "config": { }, "duration": 2648, "finished_at": "2014-04-08T19:52:56Z", "id": 22555277, "job_ids": [22555278, 22555279, 22555280, 22555281], "number": "784", "pull_request": true, "pull_request_number": "1912", "pull_request_title": "Example PR", "repository_id": 82, "started_at": "2014-04-08T19:37:44Z", "state": "failed" } ], "jobs": [ ], "commits": [ ] }
$ travis history ... $ travis show 15 # show build #15 ... $ travis restart 15 ... $ travis cancel 15 ...
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' repository = Travis::Repository.find('my/repo') repository.each_build do |build| # restart all the builds build.restart end
Attributes
| Attribute | Description |
|---|---|
| id | build id |
| repository_id | repository id |
| commit_id | commit id |
| number | build number |
| pull_request | true or false |
| pull_request_title | PR title if pull_request is true |
| pull_request_number | PR number if pull_request is true |
| config | build config (secure values and ssh key removed) |
| state | build state |
| started_at | time the build was started |
| finished_at | time the build finished |
| duration | build duration |
| job_ids | list of job ids in the build matrix |
Note that duration
might not correspond to finished_at - started_at
if the build was restarted at a later point.
List Builds
GET /builds
| Parameter | Default | Description |
|---|---|---|
| ids | list of build ids to fetch | |
| repository_id | repository id the build belongs to | |
| slug | repository slug the build belongs to | |
| number | filter by build number, requires slug or repository_id | |
| after_number | list build after a given build number (use for pagination), requires slug or repository_id | |
| event_type | limit build to given event type (push or pull_request ) |
You have to supply either ids
, repository_id
or slug
.
GET /repos/{repository.id}/builds
| Parameter | Default | Description |
|---|---|---|
| number | filter by build number | |
| after_number | list build after a given build number (use for pagination) | |
| event_type | limit build to given event type (push or pull_request ) |
GET /repos/{+repository.slug}/builds
| Parameter | Default | Description |
|---|---|---|
| number | filter by build number | |
| after_number | list build after a given build number (use for pagination) | |
| event_type | limit build to given event type (push or pull_request ) |
Show Build
GET /builds/{build.id}
GET /repos/{repository.id}/builds/{build.id}
GET /repos/{+repository.slug}/builds/{build.id}
Cancel Build
POST /builds/{build.id}/cancel
This request always needs to be authenticated.
Restart Build
POST /builds/{build.id}/restart
This request always needs to be authenticated.
Caches
GET /repos/travis-pro/billing/builds HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.com
HTTP/1.1 200 OK Content-Type: application/json { "caches": [ { "repository_id": 51007, "size": 103677795, "slug": "cache--rvm-2.0.0--gemfile-Gemfile", "branch": "master", "last_modified": "2014-03-06T16:19:49Z" } ] }
$ travis cache -r travis-pro/billing On branch master: cache--rvm-2.0.0--gemfile-Gemfile last modified: 2014-03-06 11:19:49 size: 98.87 MiB On branch mm-ruby-2.1: cache--rvm-2.0.0--gemfile-Gemfile last modified: 2013-12-28 09:42:21 size: 98.87 MiB cache--rvm-2.1.0--gemfile-Gemfile last modified: 2013-12-28 09:42:21 size: 88.02 MiB Overall size of above caches: 371.08 MiB $ travis cache -r travis-pro/billing --delete --branch mm-ruby-2.1
require 'travis' repository = Travis::Repository.find('travis-pro/billing') repository.caches.each do |cache| # delete all caches! cache.delete if cache.branch == 'mm-ruby-2.1' end # or in a single request repository.delete_caches(branch: 'mm-ruby-2.1')
Attributes
| Attribute | Description |
|---|---|
| repository_id | id of the repository the cache belongs to |
| size | compressed cache size in bytes |
| slug | cache slug (generated from env) |
| branch | branch the cache is for |
| last_modified | last time the cache was updated |
List caches
GET /repos/{repository.id}/caches
GET /repos/{+repository.slug}/caches
| Parameter | Default | Description |
|---|---|---|
| branch | limit listed caches to those on given branch | |
| match | limit listed caches to those with slug containing the given value |
This request always needs to be authenticated.
Delete caches
DELETE /repos/{repository.id}/caches
DELETE /repos/{+repository.slug}/caches
| Parameter | Default | Description |
|---|---|---|
| branch | only delete caches on given branch | |
| match | only delete caches with slug containing the given value |
This request always needs to be authenticated.
Commits
GET /repos/sinatra/sinatra/builds HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "builds": [ ], "jobs": [ ], "commits": [ { "id": 1873023, "sha": "a18f211f6f921affd1ecd8c18691b40d9948aae5", "branch": "master", "message": "Merge pull request #25 from henrikhodne/add-responses-to-documentation\n\nAdd responses to documentation", "committed_at": "2013-04-15T09:44:31Z", "author_name": "Henrik Hodne", "author_email"<EMAIL_ADDRESS>"committer_name": "Henrik Hodne", "committer_email"<EMAIL_ADDRESS>"compare_url": "https://github.com/travis-ci/travis-api/compare/0f31ff4fb6aa...a18f211f6f92" } ] }
$ travis history -r sinatra/sinatra #784 failed: master Merge pull request #861 from kant/patch-1 #783 passed: v1.4.5 v1.4.5 #782 passed: master v1.4.5
require 'travis' repository = Travis::Repository.find('my/repo') repository.each_build do |build| puts build.commit.message end
There is no API endpoint for resolving commits, however commit data might be included in other API responses, like builds or jobs.
Attributes
| Attribute | Description |
|---|---|
| id | commit id |
| sha | commit sha |
| branch | branch the commit is on |
| message | commit message |
| committed_at | commit date |
| author_name | author name |
| author_email | author email |
| committer_name | committer name |
| committer_email | committer email |
| compare_url | link to diff on GitHub |
Hooks
PUT /hooks HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org Content-Type: application/json { "hook": { "id": 42, "active": true } }
$ travis enable -r my/repo
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' Travis.hooks.each { |hook| hook.enable }
Attributes
See repository.
List Hooks
GET /hooks
This request always needs to be authenticated.
Enable/Disable Hook
PUT /hooks
| Parameter | Default | Description |
|---|---|---|
| hook[id] | id of the hook/repository | |
| hook[active] | false | whether to turn hook on (true) or off (false) |
PUT /hooks/{hook.id}
| Parameter | Default | Description |
|---|---|---|
| hook[active] | false | whether to turn hook on (true) or off (false) |
This request always needs to be authenticated.
Jobs
POST /jobs/42/restart HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
$ travis restart 1.2 -r my/repo
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' Travis.repos('my/repo').last_build.jobs.each do |job| job.restart if job.failed? end
Attributes
| Attribute | Description |
|---|---|
| id | job id |
| build_id | build id |
| repository_id | repository id |
| commit_id | commit id |
| log_id | log id |
| number | job number |
| config | job config (secure values and ssh key removed) |
| state | job state |
| started_at | time the job was started |
| finished_at | time the job finished |
| duration | job duration |
| queue | job queue |
| allow_failure | whether or not job state influences build state |
| annotation_ids | list of annotation ids |
Fetch Job
GET /jobs/{job.id}
Fetch multiple jobs
| Parameter | Default | Description |
|---|---|---|
| ids | list of job ids | |
| state | job state to filter by | |
| queue | job queue to filter by |
You need to provide exactly one of the above parameters.
If you provide state
or queue
, a maximum of 250 jobs will be returned.
Cancel Job
POST /jobs/{job.id}/cancel
This request always needs to be authenticated.
Restart Job
POST /jobs/{job.id}/restart
This request always needs to be authenticated.
Logs
GET /jobs/42/logs HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: text/plain Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type text/plain Using worker: ...
$ travis logs
... logs ...
require 'travis' rails = Travis::Repository.find('rails/rails') job = rails.last_build.jobs.first # this will live stream if the job is currently running job.log.body do |part| print part end
Attributes
| Attribute | Description |
|---|---|
| id | log id |
| job_id | job id |
| body | log body |
Chunked Attributes
You can retrieve the chunked attributes instead of the normal attributes by adding the attribute chunked=true
to the mime-type specified in the Accept
header.
| Attribute | Description |
|---|---|
| id | log id |
| job_id | job id |
| parts | log parts |
The parts
will be an array of JSON objects with the following attributes:
| Attribute | Description |
|---|---|
| number | part number |
| content | part content |
Fetching a Log
GET /logs/{log.id}
Fetching Logs as plain text
GET /jobs/{job.id}/logs
This might be necessary if the log has been archived, in which case it will result in a redirect.
Streaming Logs
To stream the logs, you will have to subscribe to the channel for the job the log belongs to on Pusher (channel is job-{job.id}
) and listen for job:log
events. The payload will have the same format as parts have in the chunked attributes API payloads.
Permissions
GET /users/permissions HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "permissions": [1, 2, 3], "admin": [1, 2], "pull": [], "push": [3] }
$ travis repos
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' Travis.user.push_access.each do |repo| puts "has push access to #{repo.slug}" end
The permissions endpoint will return arrays of repository ids:
| Key | ids for |
|---|---|
| permissions | repositories the user has access to |
| admin | repositories the user has admin access to |
| pull | repositories the user has pull access to |
| push | repositories the user has push access to |
The pull access list is only relevant for private projects.
Fetch Permissions
GET /users/permissions
This request always needs to be authenticated.
Repository Keys
GET /repos/sinatra/sinatra/key HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "public_key": "-----BEGIN RSA PUBLIC KEY-----\\nMIGJAoGBAOcx131amMqIzm5+FbZz+DhIgSDbFzjKKpzaN5UWVCrLSc57z64xxTV6\\nkaOTZmjCWz6WpaPkFZY+czfL7lmuZ/Y6UNm0vupvdZ6t27SytFFGd1/RJlAe89tu\\nGcIrC1vtEvQu2frMLvHqFylnGd5Gy64qkQT4KRhMsfZctX4z5VzTAgMBAAE=\\n-----END RSA PUBLIC KEY-----\\n", "fingerprint": "ef:39:56:6e:2a:09:a2:10:2e:b5:39:ac:3d:3e:e1:05" }
$ travis pubkey -r travis-ci/travis-api ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCOmOkC6MYRH1w2ib3AIC00GNwmgr8ch3mNHZ16x6cvSMjc6cURZt9Hav6gz03P5+9e5Vw1ztm3hvPR+IJsyOV/CSsYf1Cgboj6ZJ7tr3xOJXcqcMVfiGiG7Km6/psRdn0jrjTpU/qcru8Wx3zbQEf5NuXQyMVHmnl8/5w0WPV/Uw== $ travis pubkey --pem -r travis-ci/travis-api -----BEGIN RSA PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCOmOkC6MYRH1w2ib3AIC00GNwm gr8ch3mNHZ16x6cvSMjc6cURZt9Hav6gz03P5+9e5Vw1ztm3hvPR+IJsyOV/CSsY f1Cgboj6ZJ7tr3xOJXcqcMVfiGiG7Km6/psRdn0jrjTpU/qcru8Wx3zbQEf5NuXQ yMVHmnl8/5w0WPV/UwIDAQAB -----END RSA PUBLIC KEY----- $ travis pubkey --fingerprint -r travis-ci/travis-api 99:66:93:03:41:0b:f1:f7:61:83:16:61:fa:47:c0:8f
require 'travis' repo = Travis::Repository.find('travis-ci/travis-api') puts "SSH format: ", repo.key.to_ssh puts "PEM format: ", repo.key.to_s puts "Fingerprint: ", repo.key.fingerprint puts repository.encrypt("example")
| Attribute | Description |
|---|---|
| key | public key |
| fingerprint | fingerprint for the public key |
This key can be used to encrypt (but not decrypt) secure env vars.
Fetch a Public Key
GET /repos/{repository.id}/key
GET /repos/{+repository.slug}/key
Generate a Public Key
POST /repos/{repository.id}/key
POST /repos/{+repository.slug}/key
This will invalidate the current key, thus also rendering all encrypted variables invalid.
This request always needs to be authenticated.
Repositories
GET /repos/sinatra/sinatra HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "repo": { "id": 82, "slug": "sinatra/sinatra", "description": "Classy web-development dressed in a DSL", "last_build_id": 23436881, "last_build_number": "792", "last_build_state": "passed", "last_build_duration": 2542, "last_build_started_at": "2014-04-21T15:27:14Z", "last_build_finished_at": "2014-04-21T15:40:04Z", "github_language": "Ruby" } }
$ travis show -r travis-ci/travis-api
...
require 'travis' repos = Travis::Repository.find_all(owner_name: 'sinatra') repos.each do |repo| puts repo.slug end
Attributes
| Attribute | Description |
|---|---|
| id | repository id |
| slug | repository slug |
| description | description on githu |
| last_build_id | build id of the last build |
| last_build_number | build number of the last build |
| last_build_state | build state of the last build |
| last_build_duration | build duration of the last build |
| last_build_started_at | build started at of the last build |
| last_build_finished_at | build finished at of the last build |
| github_language | language on github |
Fetch Repository
GET /repos/{repository.id}
GET /repos/{+repository.slug}
Find Repositories
| Parameter | Default | Description |
|---|---|---|
| ids | list of repository ids to fetch, cannot be combined with other parameters | |
| member | filter by user that has access to it (github login) | |
| owner_name | filter by owner name (first segment of slug) | |
| slug | filter by slug | |
| search | filter by search term | |
| active | false |
if true , will only return repositories that are enabled |
If no parameters are given, a list or repositories with recent activity is returned.
 } }
$ travis requests -r my/repo
...
require 'travis' Travis::Repository.find('sinatra/sinatra').requests.each do |request| puts "#{request.commit.sha}: #{request.result}" end
Requests can be used to see if and why a GitHub event has or has not triggered a new build.
Attributes
| Attribute | Description |
|---|---|
| id | request id |
| commit_id | commit id |
| repository_id | repository id |
| created_at | created at |
| owner_id | owner id |
| owner_type | owner type ("User" or "Organization" ) |
| event_type | event type ("push" or "pull_request" ) |
| base_commit | base commit for pull requests |
| head_commit | head commit for pull requests |
| result | "accepted" , "rejected" or null |
| message | human readable message explaining why event has been rejected |
| pull_request | true or false |
| pull_request_number | pull request number |
| pull_request_title | pull request title |
| branch | branch commit is on |
| tag | tag if commit has been tagged |
Show Request
GET /requests/{request.id}
List Requests
GET /requests
| Parameter | Default | Description |
|---|---|---|
| repository_id | repository id the requests belong to | |
| slug | repository slug the requests belong to | |
| limit | 25 | maximum number of requests to return (cannot be larger than 100) |
| older_than | list requests before older_than (with older_than being a request id) |
You have to either provide repository_id
or slug
.
Settings: General
GET /repos/82/settings HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "settings": { "builds_only_with_travis_yml": true, "build_pushes": true, "build_pull_requests": true, "maximum_number_of_builds": 0 } }
$ travis settings Settings for travis-ci/travis-api: [-] builds_only_with_travis_yml Only run builds with a .travis.yml [+] build_pushes Build pushes [+] build_pull_requests Build pull requests 0 maximum_number_of_builds Maximum number of concurrent builds $ travis settings build_pull_requests --enable
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' repo = Travis::Repository.find('my/repo') repo.settings.build_pull_requests = false repo.settings.save
Attributes
| Attribute | Description |
|---|---|
| builds_only_with_travis_yml | “builds only with .travis.yml” setting (true or false ) |
| build_pushes | “build pushes” setting (true or false ) |
| build_pull_requests | “build pull requests” setting (true or false ) |
| maximum_number_of_builds | “maximum number of concurrent builds” setting (integer) |
Retrieve Settings
GET /repos/{repository.id}/settings
This request always needs to be authenticated.
Update Settings
PATCH /repos/{repository.id}/settings
| Parameter | Default | Description |
|---|---|---|
| settings | {} |
Hash map of settings that should be updated and their new values (see Attributes) |
This request always needs to be authenticated.
Settings: Environment Variables
GET /settings/env_vars?repository_id=124920 HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "env_vars":[ { "id": "018e66f2-cd3a-4295-aa1d-018fe9aa0fb4", "name": "example", "value": "foobar", "public": true, "repository_id": 124920 }, { "id": "ec9423da-9658-4cd6-b282-fd0e5f6ed2df", "name": "secret_example", "public": false, "repository_id": 124920 } ] }
$ travis env list example=foobar secret_example=[secure]
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' repo = Travis::Repository.find('my/repo') repo.env_vars['foo'] = bar
Attributes
| Attribute | Description |
|---|---|
| id | env var id |
| repository_id | repository id |
| name | env var name (exported) |
| value | env var value (exported, only included if public is true) |
| public | whether or not value is public |
List Variables
GET /settings/env_vars?repository_id={repository.id}
This request always needs to be authenticated.
Fetch Variable
GET /settings/env_vars/{env_var.id}?repository_id={repository.id}
This request always needs to be authenticated.
Add Variable
POST /settings/env_vars?repository_id={repository.id}
| Parameter | Default | Description |
|---|---|---|
| env_var | Hash map of env var variable (see below) | |
| env_var.name | Name of the new env var (string) | |
| env_var.value | Value of the new env var (string) | |
| env_var.public | false | whether or not to display the value |
This request always needs to be authenticated.
Update Variable
PATCH /settings/env_vars/{env_var.id}?repository_id={repository.id}
| Parameter | Default | Description |
|---|---|---|
| env_var | Hash map of env var variable (see below) | |
| env_var.name | current value | Name of the new env var (string) |
| env_var.value | current value | Value of the new env var (string) |
| env_var.public | current value | whether or not to display the value |
This request always needs to be authenticated.
Delete Variable
DELETE /settings/env_vars/{env_var.id}?repository_id={repository.id}
This request always needs to be authenticated.
Settings: SSH Key
GET /settings/ssh_key/124920 HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.com
HTTP/1.1 200 OK Content-Type: application/json { "ssh_key": { "description": "my custom key", "fingerprint": "99:66:93:03:41:0b:f1:f7:61:83:16:61:fa:47:c0:8f" } }
$ travis sshkey
No custom SSH key installed.
require 'travis/pro' Travis::Pro.access_token = 'YOUR TRAVIS ACCESS TOKEN' puts Travis::Pro::Repository.find('my/repo').ssh_key.description
Attributes
| Attribute | Description |
|---|---|
| id | ssh key id (corresponds to repository id) |
| description | key description |
| fingerprint | key fingerprint |
Fetch Key
GET /settings/ssh_key/#{ssh_key.id}
This request always needs to be authenticated.
Update or Create Key
PATCH /settings/ssh_key/#{ssh_key.id}
| Parameter | Default | Description |
|---|---|---|
| ssh_key | Hash map of ssh key data (see below) | |
| ssh_key.description | current value or empty | key description |
| ssh_key.value | private key (required) |
This request always needs to be authenticated.
Delete Key
DELETE /settings/ssh_key/#{ssh_key.id}
This request always needs to be authenticated.
Users
GET /users/ HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Authorization: token YOUR TRAVIS ACCESS TOKEN Host: api.travis-ci.org
HTTP/1.1 200 OK Content-Type: application/json { "user": { "id": 267, "name": "Konstantin Haase", "login": "rkh", "email"<EMAIL_ADDRESS>"gravatar_id": "5c2b452f6eea4a6d84c105ebd971d2a4", "is_syncing": false, "synced_at": "2014-02-27T18:53:43Z", "correct_scopes": false, "created_at": "2011-03-30T16:25:21Z" } }
$ travis whoami You are rkh (Konstantin Haase) $ travis sync synchronizing: ... done
require 'travis' Travis.access_token = 'YOUR TRAVIS ACCESS TOKEN' puts Travis.user.name Travis.user.sync
Attributes
| Attribute | Description |
|---|---|
| id | user id |
| login | user login on github |
| name | user name on github |
| primary email address on github | |
| gravatar_id | avatarid |
| is_syncing | whether or not user account is currently being synced |
| synced_at | last synced at |
| correct_scopes | whether or not github token has the correct scopes |
| channels | pusher channels for this user |
Show User
GET /users/
GET /users/{user.id}
This request always needs to be authenticated.
Sync Users
POST /users/sync
Triggers a new sync with GitHub. Might return status 409
if the user is currently syncing.
This request always needs to be authenticated.
Other Endpoints
Linting
PUT /lint/ HTTP/1.1 User-Agent: MyClient/1.0.0 Accept: application/vnd.travis-ci.2+json Host: api.travis-ci.org Content-Type: text/yaml language: ruby jdk: default
HTTP/1.1 200 OK Content-Type: application/json { "lint": { "warnings": [ { "key": ["jdk"], "message": "specified jdk, but ruby does not include jruby" } ] } }
$ travis lint example.yml Warnings for example.yml: [x] dropping jdk section: specified jdk, but ruby does not include jruby
require 'travis' content = <<-YAML language: ruby jdk: default YAML Travis.lint(content).warnings.each do |warning| puts "%p: %s" % [warning.key, warning.message] end
POST /lint
| Parameter | Default | Description |
|---|---|---|
| content | content of the .travis.yml |
PUT /lint
This is an alternative endpoint to the POST
with parameter, to make it work well with tools like curl
(curl -T .travis.yml api.travis-ci.org/lint
). The request body can contain the YAML file directly.
API Clients
There are a few API clients out there you can use for interacting with the Travis API, rather than manually triggering HTTP requests and parsing the responses.
Official
The following clients are maintained by the Travis CI team:
- travis.rb: Command line client and Ruby library
- travis-web: Web interface and JavaScript library, using Ember.js
- travis-sso: Single-Sign-On Rack middleware for Travis CI applications
Web Browsers
API requests using CORS:

With jQuery:

JSONP

When writing an in-browser client, you have to circumvent the browser’s same origin policy. Generally, we offer two different approaches for this: Cross-Origin Resource Sharing (aka CORS) and JSONP. If you don’t have any good reason for using JSONP, we recommend you use CORS.
Cross-Origin Resource Sharing
All API resources set appropriate headers to allow Cross-Origin requests. Be aware that on Internet Explorer you might have to use a different interface to send these requests.
In contrast to JSONP, CORS does not lead to any execution of untrusted code.
Most JavaScript frameworks, like jQuery, take care of CORS requests for you under the hood, so you can just do a normal ajax request.
Our current setup allows the headers Content-Type
, Authorization
, Accept
and the HTTP methods HEAD
, GET
, POST
, PATCH
, PUT
, DELETE
.
JSONP
You can disable the same origin policy by treating the response as JavaScript.
Supply a callback
parameter to use this.
This has the potential of code injection, use with caution.
Third Party
Besides the official clients, there is a range of third party client available, amongst these:
- PHP Travis Client: PHP client library
- Travis Node.js: Node.js client library
- travis-api-wrapper: Asynchronous Node.js wrapper
- travis-ci: Thin Node.js wrapper
- TravisMiner: Ruby library for mining the Travis API
- TravisPy: Python library trying to closely mimic the official Ruby client


A complete TiDB cluster contains PD, TiKV, and TiDB. To start the database service, follow the order of PD -> TiKV -> TiDB. To stop the database service, follow the order of stopping TiDB -> TiKV -> PD.
Before you start, see TiDB architecture and Software and Hardware Requirements.
This document describes the binary deployment of three scenarios:
See the following table for the default ports for the TiDB components:
| Component | Default Port | Protocol | Description |
|---|---|---|---|
| ssh | 22 | TCP | sshd service |
| TiDB | 4000 | TCP | the communication port for the application and DBA tools |
| TiDB | 10080 | TCP | the communication port to report TiDB status |
| TiKV | 20160 | TCP | the TiKV communication port |
| PD | 2379 | TCP | the communication port between TiDB and PD |
| PD | 2380 | TCP | the inter-node communication port within the PD cluster |
See the following table for the default ports for the optional TiDB components:
| Component | Default Port | Protocol | Description |
|---|---|---|---|
| Prometheus | 9090 | TCP | the communication port for the Prometheus service |
| Pushgateway | 9091 | TCP | the aggregation and report port for TiDB, TiKV, and PD monitor |
| Node_exporter | 9100 | TCP | the communication port to report the system information of every TiDB cluster node |
| Grafana | 3000 | TCP | the port for the external Web monitoring service and client (Browser) access |
| alertmanager | 9093 | TCP | the port for the alert service |
| Configuration | Description |
|---|---|
| Supported Platform | See the Software and Hardware Requirements |
| File System | The ext4 file system is recommended in TiDB Deployment |
| Swap Space | The Swap Space is recommended to close in TiDB Deployment |
| Disk Block Size | Set the size of the system disk Block to 4096 |
| Configuration | Description |
|---|---|
| Firewall / Port | Check whether the ports required by TiDB are accessible between the nodes |
| Configuration | Description |
|---|---|
| Nice Limits | For system users, set the default value of nice in TiDB to 0 |
| min_free_kbytes | The setting for vm.min_free_kbytes in sysctl.conf needs to be high enough |
| User Open Files Limit | For database administrators, set the number of TiDB open files to 1000000 |
| System Open File Limits | Set the number of system open files to 1000000 |
| User Process Limits | For TiDB users, set the nproc value to 4096 in limits.conf |
| Address Space Limits | For TiDB users, set the space to unlimited in limits.conf |
| File Size Limits | For TiDB users, set the fsize value to unlimited in limits.conf |
| Disk Readahead | Set the value of the readahead data disk to 4096 at a minimum |
| NTP service | Configure the NTP time synchronization service for each node |
| SELinux | Turn off the SELinux service for each node |
| CPU Frequency Scaling | It is recommended to turn on CPU overclocking |
| Transparent Hugepages | For Red Hat 7+ and CentOS 7+ systems, it is required to set the Transparent Hugepages to always |
| I/O Scheduler | Set the I/O Scheduler of data disks to the deadline mode |
| vm.swappiness | Set vm.swappiness = 0 |
Note: To adjust the operating system parameters, contact your system administrator.
| Configuration | Description |
|---|---|
| LANG environment | Set LANG = en_US.UTF8 |
| TZ time zone | Set the TZ time zone of all nodes to the same value |
In the Linux environment, create TiDB on each installation node as a database running user, and set up the SSH mutual trust between cluster nodes. To create a running user and open SSH mutual trust, contact the system administrator. Here is an example:
# useradd tidb
# usermod -a -G tidb tidb
# su - tidb
Last login: Tue Aug 22 12:06:23 CST 2017 on pts/2
-bash-4.2$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tidb/.ssh/id_rsa):
Created directory '/home/tidb/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/tidb/.ssh/id_rsa.
Your public key has been saved in /home/tidb/.ssh/id_rsa.pub.
The key fingerprint is:
5a:00:e6:df:9e:40:25:2c:2d:e2:6e:ee:74:c6:c3:c1 tidb@t001
The key's randomart image is:
+--[ RSA 2048]----+
| oo. . |
| .oo.oo |
| . ..oo |
| .. o o |
| . E o S |
| oo . = . |
| o. * . o |
| ..o . |
| .. |
+-----------------+
-bash-4.2$ cd .ssh
-bash-4.2$ cat id_rsa.pub >> authorized_keys
-bash-4.2$ chmod 644 authorized_keys
-bash-4.2$ ssh-copy-id -i ~/.ssh/id_rsa.pub <IP_ADDRESS>
TiDB provides the official binary installation package that supports Linux. For the operating system, it is recommended to use Redhat 7.3+, CentOS 7.3+ and higher versions.
# Download the package.
wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
wget http://download.pingcap.org/tidb-latest-linux-amd64.sha256
# Check the file integrity. If the result is OK, the file is correct.
sha256sum -c tidb-latest-linux-amd64.sha256
# Extract the package.
tar -xzf tidb-latest-linux-amd64.tar.gz
cd tidb-latest-linux-amd64
After downloading the TiDB binary package, you can run and test the TiDB cluster on a standalone server. Follow the steps below to start PD, TiKV and TiDB:
Start PD.
./bin/pd-server --data-dir=pd \
--log-file=pd.log
Start TiKV.
./bin/tikv-server --pd="<IP_ADDRESS>:2379" \
--data-dir=tikv \
--log-file=tikv.log
Start TiDB.
./bin/tidb-server --store=tikv \
--path="<IP_ADDRESS>:2379" \
--log-file=tidb.log
Use the official MySQL client to connect to TiDB.
mysql -h <IP_ADDRESS> -P 4000 -u root -D test
If you want to test TiDB but have a limited number of nodes, you can use one PD instance to test the entire cluster.
Assuming that you have four nodes, you can deploy 1 PD instance, 3 TiKV instances, and 1 TiDB instance. See the following table for details:
| Name | Host IP | Services |
|---|---|---|
| Node1 | <IP_ADDRESS> | PD1, TiDB |
| Node2 | <IP_ADDRESS> | TiKV1 |
| Node3 | <IP_ADDRESS> | TiKV2 |
| Node4 | <IP_ADDRESS> | TiKV3 |
Follow the steps below to start PD, TiKV and TiDB:
Start PD on Node1.
./bin/pd-server --name=pd1 \
--data-dir=pd1 \
--client-urls="http://<IP_ADDRESS>:2379" \
--peer-urls="http://<IP_ADDRESS>:2380" \
--initial-cluster="pd1=http://<IP_ADDRESS>:2380" \
--log-file=pd.log
Start TiKV on Node2, Node3 and Node4.
./bin/tikv-server --pd="<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv1 \
--log-file=tikv.log
./bin/tikv-server --pd="<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv2 \
--log-file=tikv.log
./bin/tikv-server --pd="<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv3 \
--log-file=tikv.log
Start TiDB on Node1.
./bin/tidb-server --store=tikv \
--path="<IP_ADDRESS>:2379" \
--log-file=tidb.log
Use the official MySQL client to connect to TiDB.
mysql -h <IP_ADDRESS> -P 4000 -u root -D test
For the production environment, multiple nodes cluster deployment is recommended. Before you begin, see Software and Hardware Requirements.
Assuming that you have six nodes, you can deploy 3 PD instances, 3 TiKV instances, and 1 TiDB instance. See the following table for details:
| Name | Host IP | Services |
|---|---|---|
| Node1 | <IP_ADDRESS> | PD1, TiDB |
| Node2 | <IP_ADDRESS> | PD2 |
| Node3 | <IP_ADDRESS> | PD3 |
| Node4 | <IP_ADDRESS> | TiKV1 |
| Node5 | <IP_ADDRESS> | TiKV2 |
| Node6 | <IP_ADDRESS> | TiKV3 |
Follow the steps below to start PD, TiKV, and TiDB:
Start PD on Node1, Node2, and Node3 in sequence.
./bin/pd-server --name=pd1 \
--data-dir=pd1 \
--client-urls="http://<IP_ADDRESS>:2379" \
--peer-urls="http://<IP_ADDRESS>:2380" \
--initial-cluster="pd1=http://<IP_ADDRESS>:2380,pd2=http://<IP_ADDRESS>:2380,pd3=http://<IP_ADDRESS>:2380" \
-L "info" \
--log-file=pd.log
./bin/pd-server --name=pd2 \
--data-dir=pd2 \
--client-urls="http://<IP_ADDRESS>:2379" \
--peer-urls="http://<IP_ADDRESS>:2380" \
--initial-cluster="pd1=http://<IP_ADDRESS>:2380,pd2=http://<IP_ADDRESS>:2380,pd3=http://<IP_ADDRESS>:2380" \
--join="http://<IP_ADDRESS>:2379" \
-L "info" \
--log-file=pd.log
./bin/pd-server --name=pd3 \
--data-dir=pd3 \
--client-urls="http://<IP_ADDRESS>:2379" \
--peer-urls="http://<IP_ADDRESS>:2380" \
--initial-cluster="pd1=http://<IP_ADDRESS>:2380,pd2=http://<IP_ADDRESS>:2380,pd3=http://<IP_ADDRESS>:2380" \
--join="http://<IP_ADDRESS>:2379" \
-L "info" \
--log-file=pd.log
Start TiKV on Node4, Node5 and Node6.
./bin/tikv-server --pd="<IP_ADDRESS>:2379,<IP_ADDRESS>:2379,<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv1 \
--log-file=tikv.log
./bin/tikv-server --pd="<IP_ADDRESS>:2379,<IP_ADDRESS>:2379,<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv2 \
--log-file=tikv.log
./bin/tikv-server --pd="<IP_ADDRESS>:2379,<IP_ADDRESS>:2379,<IP_ADDRESS>:2379" \
--addr="<IP_ADDRESS>:20160" \
--data-dir=tikv3 \
--log-file=tikv.log
Start TiDB on Node1.
./bin/tidb-server --store=tikv \
--path="<IP_ADDRESS>:2379,<IP_ADDRESS>:2379,<IP_ADDRESS>:2379" \
--log-file=tidb.log
Use the official MySQL client to connect to TiDB.
mysql -h <IP_ADDRESS> -P 4000 -u root -D test
Note:
- If you start TiKV or deploy PD in the production environment, it is highly recommended to specify the path for the configuration file using the
--config
parameter. If the parameter is not set, TiKV or PD does not read the configuration file.- To tune TiKV, see Performance Tuning for TiKV.
- If you use
nohup
to start the cluster in the production environment, write the startup commands in a script and then run the script. If not, thenohup
process might abort because it receives exceptions when the Shell command exits. For more information, see The TiDB/TiKV/PD process aborts unexpectedly.
To install and deploy the environment for TiDB monitor and alarm service, see the following table for the system information:
| Name | Host IP | Services |
|---|---|---|
| Node1 | <IP_ADDRESS> | node_export, pushgateway, Prometheus, Grafana |
| Node2 | <IP_ADDRESS> | node_export |
| Node3 | <IP_ADDRESS> | node_export |
| Node4 | <IP_ADDRESS> | node_export |
# Download the package.
wget https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-amd64.tar.gz
wget https://github.com/prometheus/node_exporter/releases/download/v0.14.0-rc.2/node_exporter-0.14.0-rc.2.linux-amd64.tar.gz
wget https://grafanarel.s3.amazonaws.com/builds/grafana-4.1.2-1486989747.linux-x64.tar.gz
wget https://github.com/prometheus/pushgateway/releases/download/v0.3.1/pushgateway-0.3.1.linux-amd64.tar.gz
# Extract the package.
tar -xzf prometheus-1.5.2.linux-amd64.tar.gz
tar -xzf node_exporter-0.14.0-rc.1.linux-amd64.tar.gz
tar -xzf grafana-4.1.2-1486989747.linux-x64.tar.gz
tar -xzf pushgateway-0.3.1.linux-amd64.tar.gz
node_exporter
on Node1, Node2, Node3 and Node4.$cd node_exporter-0.14.0-rc.1.linux-amd64
# Start the node_exporter service.
./node_exporter --web.listen-address=":9100" \
--log.level="info"
pushgateway
on Node1.$cd pushgateway-0.3.1.linux-amd64
# Start the pushgateway service.
./pushgateway \
--log.level="info" \
--web.listen-address=":9091"
$cd prometheus-1.5.2.linux-amd64
# Edit the Configuration file:
vi prometheus.yml
...
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
# scrape_timeout is set to the global default (10s).
labels:
cluster: 'test-cluster'
monitor: "prometheus"
scrape_configs:
- job_name: 'overwritten-cluster'
scrape_interval: 3s
honor_labels: true # don't overwrite job & instance labels
static_configs:
- targets: ['<IP_ADDRESS>:9091']
- job_name: "overwritten-nodes"
honor_labels: true # don't overwrite job & instance labels
static_configs:
- targets:
- '<IP_ADDRESS>:9100'
- '<IP_ADDRESS>:9100'
- '<IP_ADDRESS>:9100'
- '<IP_ADDRESS>:9100'
...
# Start Prometheus:
./prometheus \
--config.file="/data1/tidb/deploy/conf/prometheus.yml" \
--web.listen-address=":9090" \
--web.external-url="http://<IP_ADDRESS>:9090/" \
--log.level="info" \
--storage.local.path="/data1/tidb/deploy/data.metrics" \
--storage.local.retention="360h0m0s"
cd grafana-4.1.2-1486989747.linux-x64
# Edit the Configuration file:
vi grafana.ini
...
# The http port to use
http_port = 3000
# The public facing domain name used to access grafana from a browser
domain = <IP_ADDRESS>
...
# Start the Grafana service:
./grafana-server \
--homepath="/data1/tidb/deploy/opt/grafana" \
--config="/data1/tidb/deploy/opt/grafana/conf/grafana.ini"
What’s on this page
© 2018 PingCAP. All Rights Reserved.
中文


swap_ranges
|
|
| Category: algorithms |
Component type: function |
Prototype
template <class ForwardIterator1, class ForwardIterator2>
ForwardIterator2 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2);
Description
Swap_ranges swaps each of the elements in the range
[first1, last1) with the corresponding element in the range
[first2, first2 + (last1 - first1)). That is, for each integer n
such that 0 <= n < (last1 - first1), it swaps *(first1 + n)
and *(first2 + n). The return value is first2 + (last1 - first1).
Definition
Defined in algo.h.
Requirements on types
ForwardIterator1 and ForwardIterator2 must both be models of
Forward Iterator. The value types of ForwardIterator1 and
ForwardIterator2 must be convertible to each other.
Preconditions
-
[first1, last1) is a valid range.
-
[first2, first2 + (last1 - first1)) is a valid range.
-
The two ranges [first1, last1) and
[first2, first2 + (last1 - first1)) do not overlap.
Complexity
Linear. Exactly last1 - first1 swaps are performed.
Example
vector<int> V1, V2;
V1.push_back(1);
V1.push_back(2);
V2.push_back(3);
V2.push_back(4);
assert(V1[0] == 1 && V1[1] == 2 && V2[0] == 3 && V2[1] == 4);
swap_ranges(V1.begin(), V1.end(), V2.begin());
assert(V1[0] == 3 && V1[1] == 4 && V2[0] == 1 && V2[1] == 2);
Notes
See also
swap, iter_swap.
Copyright © 1996 Silicon Graphics, Inc.
|