Skip to main content

GrumPHP approves Bitbucket Pipelines!

15 Jun 2016
Tags: php grumphp docker

Today, my invitation for Bitbucket Pipelines Beta got accepted! For those who haven't heard about it: Pipelines is a Continuous Delivery tool integrated in Bitbucket. When you push your changes to your Bitbucket repository, it will spin up a Docker container and run the actions you specify. I was quite exited about the concept and immediately started to set up an automated test scenario with GrumPHP.

Configuration

The configuration of Pipelines is similar to existing services like e.g. Travis. It all starts by adding a bitbucket-pipelines.yml file to the root of your project.

bitbucket-pipelines.yml:

image: php:7.0-cli

pipelines:
  default:
    - step:
        script:
          - apt-get update && apt-get install -y git
          - php -r "readfile('https://getcomposer.org/installer');" | php
          - php composer.phar global require hirak/prestissimo
          - php composer.phar install --prefer-dist
          - ./vendor/bin/grumphp run

After every commit, the pipelines file will be loaded. Since we've added a default pipeline, it will spin up a basic PHP 7.0 container. Because it's a basic container, we'll have to install git and composer to make sure the test scenario works. The installation of these packages will happen on every commit, so it is better to create your own container which contains all the tools you need to test your code. Finally, the composer dependencies are installed and the GrumPHP command is being triggered.

Analysing the results

GrumPHP Pipelines

As you can see, the Pipelines overview page is very clean and focuses on the output of your tasks. Every commit will trigger a new run and a new results overview page. This makes it very easy to spot problems before they got merged in!

Pros

  • It is a unique service that integrates completely on your git server!
  • The interface is very simple and focuses on the errors.
  • Pipelines is integrated in every screen in Bitbucket. You get feedback about the committed code in a wink of an eye.
  • It is possible to let Pipelines handle your Continuous Delivery flow!
  • You can specify different steps per git branch.
  • It works perfectly fine with GrumPHP!
  • It is FREE!

Cons

  • The docker image is loaded from DockerHub which takes a while.
  • You can only specify 1 image, which means you cannot test every commit against multiple PHP versions.
  • It is not possible to cache the composer packages. All dependencies are downloaded on every commit.

Conclusion

Bitbucket has done a really great job creating ther unique Pipelines service! Currently it is still in Beta which means they are still working on making it even better. I hope to see some additional features like running tests on multiple images, caching volumes, ... in a near future. In a next phase, I will be playing around with the Continuous Delivery options and maybe link Pipelines with an Ansible script to automatically deploy the changes to a development server.

whois VeeWee

Selfie

Hi there!

Glad you made it to my blog. Please feel free to take a look around. You will find some interesting stuff, mostly about web development and PHP.

Still can't get enough of me? Quick! Take a look at my Twitter and Github account.