Package: buildbot-travis
This is a setup of Buildbot steps, factories and configuration helpers that
give you the best of buildbot and the best of Travis CI:Builder configuration that lives with the source codePrivate buildsnon-github SCM support (gerrit, gitlab, github, github enterpris)unlimitted build parallelization on your own infraBasically we provide a compatibility shim in buildbot that allows it to consume a.travis.ymlfile.buildbot_travis does however not support the full .travis.yml format.QuickStartFirst you need to make sure you have the proper python 2.7 environment. On ubuntu 16.04, that would mean:sudo apt-get install build-essential python-dev libffi-dev libssl-dev python-pip
pip install virtualenvThen you create a virtualenv and install buildbot_travis via pip:mkdir bbtravis
cd bbtravis
virtualenv sandbox
. ./sandbox/bin/activate
pip install buildbot_travisNow you can create a new master:bbtravis create-master masterNow you can start that new master:buildbot start masterAnd then go to the UI:http://localhost:8010which has an administration panel where to configure the projects.QuickStart With Dockerdocker run -p 8010:8010 -p 9989:9989 buildbot/buildbot-travisQuickStart With HyperIP=<yourFIPaddress>
container=`hyper run -d -e buildbotURL=http://$IP/ -p 9989:9989 -p 80:8010 buildbot/buildbot-travis`
hyper fip attach $IP $container
echo go to http://$IP/#/bbtravis/config/auth  to configure admin access
echo go to http://$IP/#/bbtravis/config/workers to configureBuildbot Nine UI Pluginbuildbot_travis is configurable via the web UI.You can edit the project list, environment variables, not_important files, deployment environments, all through the web UI.high level configuration is either stored in a yaml file or directly in the configured database.The per project config fileThis is a.travis.ymlfor a typical buildout project:language: python

before_install: python bootstrap.py
install:./bin/buildout
script: ./bin/testYou can read more about this file format on the travis-ci website:http://about.travis-ci.org/docs/user/build-configuration/But features not also mentioned on this page might not currently be supported.Supported languagesThe list of supported language is depending on your build worker configuration.With the help of docker, you can create as many images as you need worker configuration.Actually the language parameter of the defacto travis format does not fully leverage the full possibilities of what you can do with buildbot.You could think of selecting a different docker image according to the version of software you want to check.
This can avoid the time to setup the worker environment at the beginning of your travis.yml (as you would do in travis saas)Build StepsTravis provides 6 hook points for your builds:before_installinstallafter_installbefore_scriptscriptafter_scriptWe really don’t care what you run from these hooks as long as exit code 0 means
success and anything else means fail.You can provide a single command like this:install: ./bin/buildoutOr multiple commands like this:install:
  - ./configure
  - ./bin/buildoutEach element of the list in the yaml will create a single step, which is named with the first characters of your command line.If you want to create a custom name, buildbot_travis supports following syntax:script:
  - |
      # build
      ./configure
      make
  - |
      # tests
      make testsBuildbot specific featuresSteps as dictionaryOriginal Travis just create a simple shell script to run the whole CI script.
Buildbot is a little bit more powerful, and buildbot_travis can make use of it.
For this you need to go out of the travis “de-facto” standard. e.g:script:
  - |
      # build
      ./configure
      make

  - title: tests
    shell: dash
    condition: TESTS=='tests'
    cmd: make testsIf yaml parser encounters a dictionary, then it will use the following keys:title: the title of the step in the UIshell: run the cmd inside the given shell (default is bash)condition: a condition to run the step.It is evaluated as a python expression, with variables beiing the environment variable generated by your matrix.
The condition is evaluated at the time of the parsing of the yaml file.
If the condition is not met, then the step is just not inserted in the step list.cmd: The command to run.step: The buildbot step create.See below for detailled description.
if defined,shell,titleandcmdkeys are ignored..bbtravis.ymlIn order to keep working with buildbot_travis and travis.org at the same time, buildbot travis will look for a .bbtravis.yml before .travis.yml.
With this, you can keep your .travis.yml without any buildbot specific feature.Shallow CloneOriginal travis supports clone depth configuration inside the yml file (aka shallow clone).
As the git clone is made before buildbot has a chance to parse the yaml, this configuration is done in the per project config in buildbot travis.
Two options are available in the cfg.yml (shallow and retryFetch) e.g:projects:
-   branches:
    - master
    name: buildbot
    repository: https://github.com/buildbot/buildbot
    shallow: 200
    mode: "full"
    method: "clobber"
    stages: []
    tags: []
    vcs_type: githubInterpolateBuildbot has a very usefulInterpolateutility.
If you prepend your scripts by`!ior!interpolate, then buildbot_travis will automatically create an Interpolate object:- title: make dist
  cmd: !i make REVISION=%(prop:got_revision:-%(src::revision:-unknown)s)s distCommands without shellIf cmd is a list, it will run without use of shell (this can avoid to have to shell quote variables):script:-title:make distcmd:["make",!i"REVISION=%(prop:got_revision:-%(src::revision:-unknown)s)s","dist"]Buildbot Steps BatteriesBuildbot comes with battery included. It has atons of stepsin it that you could use.
What if you could contruct those steps in the bbtravis.yml?
Guess what? You can.script:-condition:TESTS=='trial'step:!Trialname:trialtests:buildbot.testEvery Buildbot steps from the buildbot.plugins.steps module is available by default.
If you want to use your own customs steps, you can do it with 2 methods.Create a buildbotplugin.
If it is installed in your master virtual environment and recognised inside buildbot.plugins.steps, it will be available in buildbot_travis yaml parser.If you want to define your custom step in your master.cfg directly, you will need to register your step directly in the yaml parser.frombuildbot_travis.travisymlimportregisterStepClassclassFancyStep(steps.ShellSequence):...registerStepClass("FancyStep",FancyStep)then in your yaml:script:-step:!FancyStepNoteYou can construct your steps either with arg list or keyword args, but not both e.g following are equivalentscript:-step:!ShellCommand"true"-step:!ShellCommand-"true"-step:!ShellCommandcommand:"true"NoteDue to the way steps are initialized,titlekey cannot be used to override the default step name.
You have to use the standardnamestep argument to specify it:script:-step:!ShellCommandcommand:"true"name:"alwayssucceed"NoteYou can also contruct your step list without passing through the dictionary structurescript:-!ShellCommandcommand:"true"name:"alwayssucceed"Status contextIf github_token is specified, bbtravis will create a github status for each of the builds of the matrix, with direct link to the sub build.
The name of the status (aka context) is calculated usingreporter_contextof the project configuration.
The default is"bb%(prop:matrix_label:+/)s%(prop:matrix_label)s".matrix_labelis computed by the Trigger step, and is the concatenation of key and values of the matrix.
because matrix can be large, and github context is limited in size, bbtravis implements a way for projects to define abbreviations for the labels.
e.g .bbtravis.yml such as:language:pythonlabel_mapping:TWISTED:twSQLALCHEMY:sqlaSQLALCHEMY_MIGRATE:sqlamlatest:lpython:pyWill generate context like:bb/py:2.6/sqla:l/sqlam:0.7.1/tw:11.1.0Notecontext reporter is for now only implemented from github, but it should be easy to adapt to Gitlab, Gerrit, etcInstalling dependenciesThe docker image that is used is throw away, and will start from clean state for each build.You can create a docker image with passwordless sudo, as travis does, so that you can use apt-get:before_install:
  - sudo apt-get update
  - sudo apt-get install -y -q mydependencyIt is however a better practice and more optimized to just provide a prebuilt docker image which contain what you need.EnvironmentsYou might want to perform multiple builds of the same piece of software. Travis
delivers:env:
 - FLAVOUR=blue
 - FLAVOUR=green
 - FLAVOUR=red

install:
  - ./configure -f $FLAVOUR
  - ./bin/buildoutCommits to this code base will cause builds for blue, green and red flavours.
The environment variables can be used like ordinary environment variables
inside the scripts you run from your.travis.ymland can be used in the.travis.ymlitself.envis a list of environment variables. You can specify multiple variables
on a single line like this:env:
 - PROP1=foo PROP2=barBuild MatrixYour options forlanguageandenvcreate an implicit build matrix. A
build matrix is a collection of all the possible combinations of theenvoptions and language versions. You can fine tine this matrix by excluding
certain combinations, or inserting additional ones.Here is an example of excluding a combination and inserting an additional
build:python:
  - 2.6
  - 2.7

env:
  - FLAVOUR=apple
  - FLAVOUR=orange

matrix:
  exclude:
    - python: 2.7
      env: FLAVOUR=orange
  include:
    - python: 2.7
      env: FLAVOUR=bananaThis will do an additional build of thebananabuild but only for python
2.7. And it will turn off the build for theorangeflavour, again only
for python 2.7.DeploymentADeploysection is available in the left side menu. In this section, a Deployment dashboard will be
available once configured.This dashboard enables a streamlined, fully automated delivery process, from Commit to Production environment.
Latest version of your project is just one click away from users.See the dashboard’s template belowDELIVERABLESSTAGES(projects)COMMITDEVQAPRODDeliverable AGIT rev1.2.3GIT tagGIT tagFor example, the version 1.2.3 (specified thanks to a GIT tag) of deliverable A is deployed in DEV stage.Here are the 5 steps to setup a Deployment dashboard in Buildbot Travis.ADeploymentsection is available in theSettingssection.
In this section, theDeployment Environment(s)is the list of target environments (or Stages)
where deliverables are going to be deployed.
These environments should be sorted following your development process definition.
Example:COMMIT (merged dev), DEV, QA, PROD
BEWARE!The first column is reserved for COMMIT stage so you do not need to define it in the Stages list.Go to theDeploysection in the left side menu. You should see a Deployment dashboard like the above example.
The Stages should be the same as the ones defined in 1).Go to theSettings/Projectssection. Add corresponding Stages to the different projects in the Stages field.
Stages can be a subset of the Stages defined in 2).You should see a fully configured Deployment dashboard with all the deliverables, Stages, GIT revisions and GIT
tags. GIT revisions and GIT tags are available in dropdown lists. When you select a specific version, a pop_up
window appears to launch the deployment procedure in the specific stage.To enable push button deployments, you need to define the deployment procedures.
Create deployment scripts and update the script and/or after_script sections of the.travis.ymlfile
of each deliverable.Example:after_script:
   - |
     # Deployment
       python ./deploy.py --repo "${repository}" --stage "${stage}" --version "${version}";

       ${repository} is the URL of the project's (or deliverable's) repo.
       ${stage} is the retrieved from the Deployment dashboard.
       ${version} is retrieved from the Deployment dashboard.How it worksThe basic behaviour is:Commit is picked up (polling by default, with additional triggers via/change_hook/poller?poller=pollernameweb hookBuild is scheduled on a ‘spawner’ builder - this is a builder configured to
use an ordinary slaveCheckout occurs - for the purposes of acquiring the.travis.ymlrather
than for actually performing a build‘spawner’ triggers a build on a ‘job’ builder for each environment in the
build matrix defined in.travis.yml‘job’ builder does a single build in a clean latent buildslave (VM or docker)setup-stepsstep dynamically appends ShellCommand steps based on
contents of.travis.ymlwhen job is over VM orcontainer is thrown away.The ‘spawner’ build acts as a way of aggregating the build results in a
single pass/fail status.MailNotifier subclass uses.travis.ymlfound in build history so that
recipients list and whether or not to mail can be adapted accordingly.
XXX: this needs to be adapted for nineCommandLinebuildbot_travispackage comes with abbtraviscommand line utility.This utility is useful to test travis.yml locally without pushing it to the CI.
It allows to test either the travis.yml and the docker image used to run the workers.
It allows to run only the part of the matrix that you are working onExample:bbtravis run -d tardyp/metabbotcfg  -j8 TESTS=trial TWISTED=latestThis will run the resulting tests in parallel using docker image tagged tardyp/metabbotcfg and will filter only the matrix environment with TESTS==’trial’ and TWISTED==’latest’UI is using urwid console UI framework, and will split the terminal into several terminal showing each matrix run.
You can scroll using mouse wheel, and click to zoom and get more details.NoteFor nowbbtraviscommand line utility to note support Buildbot step battery nor Interpolate contructsTODOThis special branch is the nine port of buildbot_travis.
Compared to previous version following features are not yet availableCustom MailNotifier needs to be adapted for nine data api, in order to get the .travis.yml configurationmergerequest should be adapted to the new collapseRequest apiSVN shall be validated (only git has been tested so far)metrics facility is not really specific to travis, and should be available in buildbot master directlynextBuild feature shall be reimplemented: allowed to avoid running a spawner when no ‘-job’ slave is availableCompared to original Travis format, here is a non-exaustive list of features known not to be supportedafter_success, after_failure. Not implemented, but easy to add.deploy. Deployment step would have to happen after all the matrix subbuilds are succeedAnd configure your hyper keys in the default hyper worker
You should also configure an authentication plugin in order to protect those keys.