Bitbucket Pipelines (the CI system) for Perl projects

Create a local git repository

Create an empty repository on Bitbucket

Enable Pipelines

You could visit the Pipelines entry on the web page and select a language, but I have not seen Perl mentioned there so let's do it our way.

All you need to do is create a file called bitbucket-pipelines.yml with the proper content and add it to the root of your repository and push it out to Bitbucket.

Sample content for the bitbucket-pipelines.yml file.

image: perl:5.26

    - step:
          - perl -v

Then visit the page of your repository on Bitbucket and click on the Pipelines entry on the left hand side.

It will recognize your file, validate it, and ofer you to click on the "enable" button at the bottom of the screen.

Once you did that everything is set. The pipeline will run every time you push out new code to your repository.

One strange thing is that despite having the bitbucket-pipelines.yml file already committed, Bibucket still added an empty commit when I pressed the "enable" button. You'll have to pull it down to you local clone of the repository.

What is this configuration?

The above configuration tells Bitbucket to use the Perl 5.26 Docker image and run perl -v on it.

The listing of the results will looks something like this:

If you click on the link you'll see the details:

You can then click on the individual stages to see the output of each stage.

Running a Perl script in the Bitbucket pipeline

For the next experiment we added a new file to the reposiitory called with the following content:

use strict;
use warnings;


and also changed the bitbucket-pipelines.yml file to execute the instead of just showing the version number of Perl.

image: perl:5.26

    - step:
          - perl

Once we push this out to Bitbucket it will load the Docker image and run our script. The result looks like this:

The pipeline reports failure as our script exited with 1 that indicates a failure. (0 indicates succcess any other number indicates failure.)

Fixing the failure

Changing the exit(1); to exit(0);, commiting the code and pushing it out again.

This time the pipeline was succesful as you can also see in the listings: