Skip to content

BitBucket Repository Tools

⬅ Parent


bitbucketContainer

Return Code: 1 - If already inside docker, or the

Usage

bitbucketContainer [ envFile ] [ extraArgs ]

Return Code: 1 - If already inside docker, or the environment file passed is not valid Return Code: 0 - Success Return Code: Any - docker run error code is returned if non-zero

Run the default build container for build testing on BitBucket

Arguments

  • envFile - One or more environment files which are suitable to load for docker; must be valid
  • extraArgs - The first non-file argument to bitbucketContainer is passed directly through to docker run as arguments

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

isBitBucketPipeline

Are we currently in the BitBucket pipeline?

Usage

isBitBucketPipeline

Are we currently in the BitBucket pipeline? Return Code: 0 - is BitBucket pipeline Return Code: 1 - Not a BitBucket pipeline

Arguments

  • none

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

bitbucketGetVariable

Fetch a value from the pipelines YAML file

Usage

bitbucketGetVariable [ varName ] [ defaultValue ]

Fetch a value from the pipelines YAML file

Assumes current working directory is project root.

Simple get value of a variable from the bitbucket-pipelines.yml file. It's important to note that this does not parse the YML. This is useful if you have a database container as part of your build configuration which requires a root password required in other scripts; this means you do not have to replicate the value which can lead to errors.

An example bitbucket-pipelines.yml file may have a header which looks like this:

definitions:
caches:
    apt-lists: /var/lib/apt/lists
    apt-cache: /var/cache/apt
services:
    mariadb:
    memory: 1024
    image: mariadb:latest
    variables:
        MARIADB_ROOT_PASSWORD: super-secret

On this file, the value of $(bitbucketGetVariable MARIADB_ROOT_PASSWORD) is super-secret; it uses grep and sed to extract the value.

Arguments

  • varName - Name of the value to extract from bitbucket-pipelines.yml
  • defaultValue - Value if not found in pipelines

Examples

MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD:-$(bitbucketGetVariable MARIADB_ROOT_PASSWORD not-in-bitbucket-pipelines.yml)}

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

bitbucketPRNewURL

Compute the URL to create a new PR

Usage

bitbucketPRNewURL [ organization ] [ repository ]

Compute the URL to create a new PR

Arguments

  • organization - String. Organization name.
  • repository - String. Repository name.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error