Bitbucket Pipelines


Bitbucket Pipelines makes it very easy to do Continuous Integration.

You can configure Bitbucket Pipelines by adding a bitbucket-pipelines.yml file to the root of your repository.


See our full Bitbucket Pipelines example to see how easy it is to use TestingBot with Bitbucket Pipelines.


Configuration



1. Go to your Bitbucket repository settings and add the following environment variables:

TB_KEY: Your TestingBot Key
TB_SECRET: Your TestingBot Secret


2. Configure bitbucket-pipelines.yml with the example configuration below:

image: ruby:2.1
pipelines:
  default:
    - step:
        script:
          - apt-get update
          - apt-get install unzip
          - bundle install
          - bundle exec rackup -p 8001 > /dev/null &
          - ./run_local.bash
          - bundle exec rspec spec/welcome.rb
          - pkill -9 rackup



The run_local.bash script will download our TestingBot Tunnel


#!/bin/bash -e

wget https://testingbot.com/tunnel/testingbot-tunnel.jar
java -jar testingbot-tunnel.jar ${TB_KEY} ${TB_SECRET} > /dev/null &
sleep 10


3. Read the Bitbucket environment variables in your test. For example, with RSpec:


require 'selenium-webdriver'
require 'rspec'

RSpec.configure do |config| config.color_enabled = true end

describe "The welcome demo" do

  before(:all) do
    testingbot_key = ENV['TB_KEY']
    testingbot_secret = ENV['TB_SECRET']
    caps = Selenium::WebDriver::Remote::Capabilities.new
    caps['platform'] = 'WINDOWS'
    caps['version'] = 'latest'
    caps['browserName'] = 'chrome'
    caps['build'] = 'Bitbucket Pipeline'
    caps['name'] =  'Bitbucket Pipeline'
    @driver = Selenium::WebDriver.for(:remote, :url => "http://#{testingbot_key}:#{testingbot_secret}@hub.testingbot.com/wd/hub", :desired_capabilities => caps)
 end

  after(:all) do
    @driver.quit
  end

  it "should have a welcome page" do
    username = 'Test User'
    @driver.get 'http://localhost:8001'
    @driver.find_element(:name ,'name').send_keys username
    @driver.find_element(:css, "input[type='submit']").click
    actual_text = @driver.find_element(:css, "h2").text
    actual_text.should == "Welcome, #{username}"
  end

end