Pipeline Authentication
BitBucket Pipelines

BitBucket Pipelines

In order to use Craftable PRO in BitBucket pipelines we must authorize composer to access private repository

To authorize composer in BitBucket pipelines we will add new BitBucket repository variable and extend our bitbucket-pipelines.yml with COMPOSER_AUTH enviroment variable.

Add a new key in Respository Settings

In BitBucket under Respository Settings navigate to Repository Variables and add new variables with secured checked in ✅

key:    CRAFTABLE_PRO_EMAIL
value:  <your-email-address-you-purchased-licence-with>
key:    CRAFTABLE_PRO_LICENCE_KEY
value:  <your-licence-key>

Add COMPOSER_AUTH in your bitbucket-pipelines.yml

Under scripts of your bitbucket-pipelines.yml composer build step, add following line

COMPOSER_AUTH='{"http-basic":{"packages.craftable.pro":{"username":"'$CRAFTABLE_PRO_EMAIL'","password":"'$CRAFTABLE_PRO_LICENCE_KEY'"}}}' composer install --no-interaction --prefer-dist

Example of a build step of bitbucket-pipelines.yml

services:
    testing:
      image: postgres:14
      environment:
        POSTGRES_DB: 'homestead'
        POSTGRES_USER: 'homestead'
        POSTGRES_PASSWORD: 'secret'
  steps:
    - step: &unit-testing
        name: Build composer dev + Unit Testing
        caches:
          - composer
        script:
          - echo "memory_limit = 256M" > $PHP_INI_DIR/conf.d/php-memory-limits.ini
          - php -r "file_exists('.env') || copy('.env.example', '.env');"
        	- COMPOSER_AUTH='{"http-basic":{"packages.craftable.pro":{"username":"'$CRAFTABLE_PRO_EMAIL'","password":"'$CRAFTABLE_PRO_LICENCE_KEY'"}}}' composer install --no-interaction --prefer-dist
          - php artisan key:generate
          - vendor/bin/phpunit --configuration phpunit.bitbucket.xml
        services:
          - testing
        artifacts:
          - vendor/**
Last updated on March 21, 2023