Bitbucket Pipe


#Bitbucket Pipe

#Introduction

The PrestaFlow Bitbucket Pipe runs your PrestaFlow test suites inside a Bitbucket Pipelines step. It is a companion of the GitHub Action and the GitLab CI/CD component — same behavior, same backend, different CI idiom. Optionally boot a PrestaShop Flashlight instance, execute your suite, upload results (plus error and visual-regression screenshots), and comment the summary on the pull request.

#Requirements

  • Bitbucket Pipelines with Docker enabled on the step (services: [docker]) whenever FLASHLIGHT=true.
  • Two repository variables (Repository settings → Repository variables):
    • PRESTAFLOW_TOKEN (Secured) — PrestaFlow API token.
    • PRESTAFLOW_BITBUCKET_TOKEN (Secured, optional) — Bitbucket Repository Access Token with pullrequest:write scope, used to post PR comments.

#Quick start

The minimal bitbucket-pipelines.yml below runs the pipe on every pull request:

Copied!
1image: php:8.3-cli
2 
3pipelines:
4 pull-requests:
5 '**':
6 - step:
7 name: PrestaFlow
8 services: [docker]
9 script:
10 - pipe: docker://prestaflow/pipe-push:1.0.0
11 variables:
12 TOKEN: $PRESTAFLOW_TOKEN
13 PROJECT_ID: pk_01ABC...
14 FLASHLIGHT: 'true'
15 PS_VERSION: '9.0.0'
16 BITBUCKET_ACCESS_TOKEN: $PRESTAFLOW_BITBUCKET_TOKEN

#Variables reference

Name Default Description
TOKEN (required) PrestaFlow API token.
PROJECT_ID "" PrestaFlow project Product Key (e.g. pk_01ABC…).
API_URL https://api.prestaflow.io PrestaFlow API base URL.
EXECUTE true Run composer run prestaflow:json:file before upload. Set to false if a previous step already produced results.json.
SUITES "" Comma-separated suites to run (e.g. BackOffice,FrontOffice). Empty runs all.
FLASHLIGHT false Boot a PrestaShop Flashlight Docker container to test against. Requires services: [docker].
PS_VERSION latest Flashlight image tag when FLASHLIGHT=true.
FLASHLIGHT_MOUNT auto Where to mount the workspace inside the Flashlight container: auto, root, modules, or themes. auto reads composer.json type (prestashop-module / prestashop-theme).
FLASHLIGHT_INIT_SCRIPTS "" Path (absolute or relative to the workspace) to a directory of Flashlight init scripts, mounted read-only at /tmp/init-scripts.
PR_COMMENT auto Post/update a PR summary comment. Defaults to true on pull-request pipelines, false otherwise.
UPLOAD_ARTIFACTS true Copy results.json (and prestaflow.env) into $BITBUCKET_PIPE_SHARED_STORAGE_DIR.
VISUAL true Enable visual-regression round-trip (baseline download before the run, actual/diff upload after).
BITBUCKET_ACCESS_TOKEN "" Access token used to post PR comments. See PR comments.

#Outputs

After the pipe runs, it writes prestaflow.env into the workspace and into $BITBUCKET_PIPE_SHARED_STORAGE_DIR/prestaflow.env (when available). The file contains:

Copied!
1PRESTAFLOW_REPORT_ID=… # PrestaFlow report ID
2PRESTAFLOW_REPORT_URL=… # https://prestaflow.io/reports/…
3PRESTAFLOW_PASSED=42
4PRESTAFLOW_FAILED=0
5PRESTAFLOW_SKIPPED=3
6PRESTAFLOW_TOTAL=45
7PRESTAFLOW_DURATION_MS=185432
8PRESTAFLOW_STATUS=success # or "failure"

Consume it in a later step by declaring artifacts: [prestaflow.env] on the pipe step and sourcing it downstream:

Copied!
1- step:
2 name: PrestaFlow
3 services: [docker]
4 artifacts: [prestaflow.env]
5 script:
6 - pipe: docker://prestaflow/pipe-push:1.0.0
7 variables:
8 TOKEN: $PRESTAFLOW_TOKEN
9 PROJECT_ID: pk_01ABC...
10 
11- step:
12 name: Notify
13 script:
14 - . prestaflow.env
15 - echo "Report ready → $PRESTAFLOW_REPORT_URL ($PRESTAFLOW_STATUS)"

#PR comments

When the pipe runs on a pull-request pipeline and BITBUCKET_ACCESS_TOKEN is set, it posts (or updates) a summary comment via the Bitbucket Cloud API. Idempotency is done via a hidden marker (<!-- prestaflow-run:<project-key> -->) inside the comment body, so subsequent pushes update the existing comment rather than appending a new one.

To create the token:

  1. Repository settings → Access tokens → Create Repository Access Token.
  2. Grant it Pull requests: write.
  3. Add it as a Secured repository variable (e.g. PRESTAFLOW_BITBUCKET_TOKEN) and pass it as BITBUCKET_ACCESS_TOKEN.

If the token is missing, the pipe warns and continues — PR comments are non-fatal.

#Flashlight

Setting FLASHLIGHT: 'true' boots a prestashop/prestashop-flashlight:<PS_VERSION> container plus a mariadb:lts sidecar, waits for the storefront to answer, and exports PRESTAFLOW_FO_URL into .env.local for your test suite. The step needs services: [docker].

FLASHLIGHT_MOUNT:

  • auto (default): reads composer.json type and mounts under modules/<name> or themes/<name>; falls back to modules/<repo-basename> with a warning.
  • root: mount workspace at /var/www/html (custom PrestaShop distributions).
  • modules / themes: force the location.

The compatibility rules that apply to the GitHub Action's Flashlight guide apply here as well: match PS_VERSION at least at the major.minor level to the code you are mounting. See the GitHub Action guide for the full compatibility notes.

#What the pipe does

The container's entrypoint runs these scripts in order — each is a small self-contained bash script:

  1. flashlight.sh — boot Flashlight (opt-in).
  2. visual-download.sh — pull visual baselines for the current branch.
  3. runner.sh — composer run prestaflow:json:file (unless EXECUTE=false).
  4. upload.sh — POST results.json + error/visual PNGs to the PrestaFlow API.
  5. comment-pr.sh — post/update the PR comment.
  6. outputs.sh — aggregate final counters and exit non-zero on any test failure.

#Publishing

The pipe is distributed as prestaflow/pipe-push:<version> on Docker Hub:

Copied!
1docker build -t prestaflow/pipe-push:1.0.0 \
2 -t prestaflow/pipe-push:1 \
3 -t prestaflow/pipe-push:latest .
4docker push prestaflow/pipe-push:1.0.0
5docker push prestaflow/pipe-push:1
6docker push prestaflow/pipe-push:latest

To submit the pipe on the Bitbucket Marketplace, register the repository at https://bitbucket.org/product/features/pipelines/integrations. Marketplace listings point to the same pipe.yml / Docker image; there is no separate artifact to publish.

#Troubleshooting

  • services: [docker] missing / Docker daemon not available — required whenever FLASHLIGHT=true. Add services: [docker] on the step.
  • PR comment not posted — the pipe needs BITBUCKET_ACCESS_TOKEN (Repository Access Token with pullrequest:write). Without it, the pipe logs a warning and continues.
  • Flashlight not ready after 240000ms — the shop container failed to respond within four minutes. See the GitHub Action troubleshooting section — the same causes and remedies apply.