Travis en la Línea de Comandos

The travis gem includes both a command line client and a Ruby library to interface with a Travis CI service. Both work with travis-ci.org, travis-ci.com or any custom Travis CI setup you might have. Check out the installation instructions to get it running in no time.

The Travis Client

Véase The Travis Client.

login

The login command will ask you for your GitHub user name and password.

We can also create a GitHub token on our own and supply it via --github-token:

$ travis login  --github-token xxxxxxxxxxxxxxxxxxxxxxxxxxxx  --pro
Successfully logged in as crguezl!
[~/sinatra/sinatra-number_cruncher(master)]$ travis whoami
You are crguezl (Casiano Rodriguez-Leon)
Para obtener el token que usamos como argumento de --github-token nos vamos a
GitHub -> settings -> Applications -> Generate new token

Véase el tutorial Creating an access token for command-line use.

init

When setting up a new project, we can run travis init to generate a .travis.yml and enable the project:

[~/sinatra/sinatra-number_cruncher(master)]$ travis init ruby --rvm 2.1.2 -r crguezl/number_cruncher
.travis.yml file created!
crguezl/number_cruncher: enabled :)

A file called .travis.yml was created that contains information about our app.

[~/sinatra/sinatra-number_cruncher(master)]$ cat .travis.yml
language: ruby
rvm: 2.1.2

Ejecutando las pruebas en Travis

A build on Travis is initialized when we push to our Github account, so do that now:

[~/sinatra/sinatra-number_cruncher(master)]$ git add .travis.yml Rakefile
[~/sinatra/sinatra-number_cruncher(master)]$ git commit -am '.travis.ym added'
[master b25b8e8] .travis.ym added
 2 files changed, 7 insertions(+), 1 deletion(-)
[~/sinatra/sinatra-number_cruncher(master)]$ git push origin master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 466 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To git@github.com:crguezl/number_cruncher.git
   5e51ec1..b25b8e8  master -> master

show

To check the status of the build, run the following command in a terminal:

[~/sinatra/sinatra-number_cruncher(master)]$ travis show -r crguezl/number_cruncher
no build yet for crguezl/number_cruncher
Travis can take a while to run a build, so you might get a message like the one above. Let us try again:

[~/sinatra/sinatra-number_cruncher(master)]$ travis show -r crguezl/number_cruncher
Job #1.1:  .travis.ym added
State:         passed
Type:          push
Branch:        master
Compare URL:   https://github.com/crguezl/number_cruncher/compare/5e51ec1d8a3a...b25b8e8d7086
Duration:      18 sec
Started:       2014-09-24 17:09:38
Finished:      2014-09-24 17:09:56
Allow Failure: false
Config:        rvm: 2.1.2
[~/sinatra/sinatra-number_cruncher(master)]$
This time we got confirmation that the build has passed successfully.

logs

Given a job number, logs simply prints out that job's logs. By default it will display the first job of the latest build.
[~/sinatra/sinatra-number_cruncher(master)]$ travis logs -r crguezl/number_cruncher
displaying logs for crguezl/number_cruncher#1.1
Using worker: worker-linux-6-2.bb.travis-ci.org:travis-linux-2

$ git clone --depth=50 --branch=master git://github.com/crguezl/number_cruncher.git crguezl/number_cruncher
Cloning into 'crguezl/number_cruncher'...
remote: Counting objects: 36, done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 36 (delta 11), reused 28 (delta 7)
Receiving objects: 100% (36/36), 4.63 KiB | 0 bytes/s, done.
Resolving deltas: 100% (11/11), done.
Checking connectivity... done.
$ cd crguezl/number_cruncher
$ git checkout -qf b25b8e8d70861b82c1399f87ebab036a180bc653
couchdb stop/waiting
$ rvm use 2.1.2 --install --binary --fuzzy
.....

open

travis open -r crguezl/number_cruncher

Opens the project view in the Travis CI web interface.

Status Images

With Travis CI, you can embed little status icons into your project's README.md or general documentation. That way, visitors of your projects or site can immediately see its build status.

<a href="https://travis-ci.org/crguezl/sinatra-capybara-selenium">
<img src="https://travis-ci.org/crguezl/sinatra-capybara-selenium.svg?branch=master alt="Build Status" />
<img src="https://travis-ci.org/crguezl/sinatra-capybara-selenium.svg?branch=master 
alt="Build Status" />
</a>

The URLs for status images are available on your repositories' page on Travis CI.

You'll find the most current status image in the top right.

Clicking that will reveal a dialog that allows you to copy and paste the URL and ready to use templates for common markup formats, like Markdown or Textile.

Make sure to select the right branch in the dropdown. The default URL, without the branch parameter, will return the status for the latest build, on any branch. Selecting the desired branch makes sure your image only displays the status for the branch whose stability is most relevant.

Travis console

[~/sinatra/sinatra-selenium/capybara-selenium(master)]$ travis console
>> .ls
Gemfile           README.md         my_sinatra_app.rb
Gemfile.lock      Rakefile          spec
>> .uname -a
Darwin air.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
>> User.current
=> #<User: crguezl>
>> Repository.find('crguezl/sinatra-capybara-selenium')
=> #<Repository: crguezl/sinatra-capybara-selenium>
>> _.last_build
=> #<Travis::Client::Build: crguezl/sinatra-capybara-selenium#13>



Subsecciones
Casiano Rodriguez León 2015-01-07