Bitbucket Pipelines Pipe
Gwenn Berry avatar
Written by Gwenn Berry
Updated over a week ago

To trigger automated tests from a BitBucket pipelines build, all you need to do is add a Miqa Update pipe into your pipeline file. Follow the instructions below to copy a code snippet into your pipeline YAML.


YAML Definition

Add the following snippet(s) to the script section of your bitbucket-pipelines.yml file:

Snippet: connection

Check your API connection (for setup purposes only).

- pipe: docker://magnalabs/bitbucket-pipe-facet-update:1.0.0
variables:
FACET_API_KEY: <your_api_key>
FACET_CLIENT_ID: <your_client_id>
BITBUCKET_COMMIT: $BITBUCKET_COMMIT
BITBUCKET_REPO_SLUG: $BITBUCKET_REPO_SLUG
FACET_ENDPOINT: connection

Snippet: trigger

Execute tests based on test trigger.

- pipe: docker://magnalabs/bitbucket-pipe-facet-update:1.0.0
variables:
FACET_API_KEY: <your_api_key>
FACET_CLIENT_ID: <your_client_id>
BITBUCKET_COMMIT: $BITBUCKET_COMMIT
BITBUCKET_REPO_SLUG: $BITBUCKET_REPO_SLUG
DOCKER_URI: <your_docker_uri>
FACET_ENDPOINT: trigger
TESTTRIGGER_ID: <your_test_name>

Variables

For most use cases, only the DOCKER_URI variable will be changing from build to build. When pushing your new Docker version, you should capture its URI (either by declaring a unique tag before pushing or retrieving the unique build hash after pushing). All other variables are either static configurations or variables that can be directly passed from Bitbucket Pipeline and Repository variables.

Shared Variables

User Variables

Variable

Usage

FACET_API_KEY (*)

The API key used by the Miqa API to identify your app.

FACET_CLIENT_ID (*)

The client ID used by the Miqa API to identify your app.

ENDPOINT

Which function to execute: trigger or connection. Default: trigger.

DEBUG

Turn on extra debug information. Default: false.

Bitbucket Pipeline Default Variables

These variables are pre-populated for you by Bitbucket Pipelines. There is no need to configure or set them, just pass them directly to the pipe with their names.

Variable

Usage

BITBUCKET_COMMIT (*)

The commit hash of a commit that kicked off the build. From default Bitbucket variable.

BITBUCKET_REPO_SLUG (*)

The URL-friendly version of a repository name. From default Bitbucket variable.

Function-Specific Variables

Variable

Usage

DOCKER_URI

URI to the new docker image, when using trigger function.

(*) = required variable.

Prerequisites

You must already have an account with Miqa and the appropriate components configured and linked to your target Docker repositories. For more information, contact [email protected].

Examples

Basic example:

script:
- pipe: docker://magnalabs/bitbucket-pipe-facet-update:1.0.0
variables:
FACET_API_KEY: $FACET_API_KEY
FACET_CLIENT_ID: $FACET_CLIENT_ID
FACET_ENDPOINT: 'trigger'
DOCKER_URI: 'us.gcr.io/my-project/my-docker-repo:my-tag'
TESTTRIGGER_ID: 'abc123'
BITBUCKET_COMMIT: $BITBUCKET_COMMIT
BITBUCKET_REPO_SLUG: $BITBUCKET_REPO_SLUG

Note: We recommend storing your API Keys as secured Repository Variables in your Bitbucket Repository. See the Official Bitbucket Pipelines Documentation for details.

Support

If you’d like help with this pipe, or you have an issue or feature request, let us know. The pipe is maintained by [email protected].

If you’re reporting an issue, please include:

  • the version of the pipe

  • relevant logs and error messages

  • steps to reproduce

Please note: earlier versions of the Bitbucket-side documentation for this pipe incorrectly list the TESTTRIGGER_ID variable as TEST_TRIGGER_ID. Please use the variable listed here, i.e. TESTTRIGGER_ID.

Known Issues

The pipe will fail on commit IDs that are fully numeric. This can be handled by re-running your pipeline directly from the Bitbucket pipeline run UI, which will force Bitbucket to use the 40-character SHA instead.

Did this answer your question?