Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Bitbucket pipelines and perl

by Skeeve (Parson)
on Mar 27, 2018 at 12:46 UTC ( [id://1211840]=perlquestion: print w/replies, xml ) Need Help??

Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

Here at work bitbucket is used.

Now I wrote a script in perl which requires MediaWiki::API and this script should be run after each push to our repository.

Do you have experience with bitbucket pipelines? How could I get a proper pipeline environment to run my script?


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re: Bitbucket pipelines and perl
by mryall (Initiate) on Mar 28, 2018 at 01:04 UTC

    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>

      WOW

      That really great and very well explained.

      Thanks a thousand times. This will really help me a lot.

      Too bad I only can give this ++ one time.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Re: Bitbucket pipelines and perl
by choroba (Cardinal) on Mar 27, 2018 at 12:53 UTC
    We used bitbucket at $job - 1, so I don't know the details anymore. The documentation contains Using Repository Hooks, it might be relevant.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: Bitbucket pipelines and perl
by karlgoethebier (Abbot) on Mar 28, 2018 at 10:02 UTC
    "...at work bitbucket is used."

    Nice ;-) The inevitable link for all the other uninitiated.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1211840]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found