Thanks for the question! Bitbucket Pipelines PM (and old Perl hacker) here.
Bitbucket Pipelines runs your code in a Docker image, and there are official Perl Docker images available you can get started with. Here's a short example that you can drop straight into bitbucket-pipelines.yml in your repository:
pipelines:
default:
- step:
image: perl:5.26
script:
- perl -v
- cpan -T "MediaWiki::API"
- perl -MMediaWiki::API -e 'my $mw = MediaWiki::API->new()'
I've run this myself in a demo pipeline here, and it works. Your code is automatically checked out by Pipelines, so you just need to edit the above to call your make commands or whatever build process you want to run.
Installing dependencies like this as part of your build process is not ideal because it slows down every build. Looking at my build, it took about 40s to install the MediaWiki module. There are two options for improving this:
First and easiest is to enable local::lib and set up a cache for the CPAN metadata and module directories, which you can see in a later commit here. The resulting configuration looks like this:
pipelines:
default:
- step:
image: perl:5.26
caches:
- perl
- cpan
script:
- cpan -T "local::lib"
- eval "$(perl -Mlocal::lib=${PWD}/perl_modules)" # set local lib to ./perl_modules
- cpan -T "MediaWiki::API"
- perl -MMediaWiki::API -e 'my $mw = MediaWiki::API->new()'
definitions:
caches:
perl: perl_modules
cpan: /root/.cpan
Once you have a successful build, this configuration will upload the /root/.cpan/ and perl_modules/ directories to a cache in S3, then retrieve them for subsequent builds. The build takes about 20s less once the caches are populated.
A more permanent way to manage build dependencies is to build a Docker image with your requirements pre-installed. This is surprisingly easy, and can be done with another repo on Bitbucket with a simple Dockerfile. We have some examples and links in our documentation on how to do this.
Good luck - hopefully this is enough to get you started with Perl on Bitbucket Pipelines!
-- Matt Ryall <mryall@atlassian.com>
|