esp.bitbucket.bitbucket_branch (1.4.1) — module

Manage repository branches on Bitbucket Server

| "added in version" 1.0.0 of esp.bitbucket"

Authors: Krzysztof Lewandowski (@klewan), Pawel Smolarz

Install collection

Install with ansible-galaxy collection install esp.bitbucket:==1.4.1


Add to requirements.yml

  collections:
    - name: esp.bitbucket
      version: 1.4.1

Description

Manages repository branches on Bitbucket Server.

It creates a new branch, or sets an existing branch as a default for the supplied repository.

Authentication can be done with I(token) or with I(username) and I(password).

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create branch and set it as default one for the supplied repository
  esp.bitbucket.bitbucket_branch:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    validate_certs: no
    state: present
    branch: feature/baz
    from_branch: master
    is_default: True
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
    
- name: Create branch
  esp.bitbucket.bitbucket_branch:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    validate_certs: no
    state: present
    branch: feature/baz
    from_branch: master
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update the default branch of a repository
  esp.bitbucket.bitbucket_branch:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    validate_certs: no
    branch: develop
    is_default: True

Inputs

    
url:
    description:
    - Bitbucket Server URL.
    required: false
    type: str

sleep:
    default: 5
    description:
    - Number of seconds to sleep between API retries.
    type: int

state:
    choices:
    - present
    default: present
    description:
    - Whether the branch should exist or not. Only creation allowed
    required: false
    type: str

token:
    description:
    - Token parameter for authentication.
    - This is only needed when not using I(username) and I(password).
    required: false
    type: str

branch:
    aliases:
    - name
    description:
    - Branch name to create or delete
    required: true
    type: str

retries:
    default: 3
    description:
    - Number of retries to call Bitbucket API URL before failure.
    type: int

password:
    description:
    - Password used for authentication.
    - This is only needed when not using I(token).
    - Required when I(username) is provided.
    required: false
    type: str

username:
    aliases:
    - user
    description:
    - Username used for authentication.
    - This is only needed when not using I(token).
    - Required when I(password) is provided.
    required: false
    type: str

use_proxy:
    default: true
    description:
    - If C(no), it will not use a proxy, even if one is defined in an environment variable
      on the target hosts.
    type: bool

is_default:
    default: false
    description:
    - Set the new branch as default one for the repository.
    required: false
    type: bool

repository:
    description:
    - Repository name.
    required: true
    type: str

from_branch:
    default: master
    description:
    - New branch will be created from this branch.
    - Required when I(state=present).
    required: false
    type: str

project_key:
    aliases:
    - project
    description:
    - Bitbucket project key.
    required: true
    type: str

return_content:
    default: true
    description:
    - Whether or not to return the body of the response as a "content" key in the dictionary
      result no matter it succeeded or failed.
    type: bool

validate_certs:
    default: true
    description:
    - If C(no), SSL certificates will not be validated.
    - This should only set to C(no) used on personally controlled sites using self-signed
      certificates.
    type: bool

Outputs

branch:
  description: A specific branch name.
  returned: always
  sample: develop
  type: str
from_branch:
  description: A source branch name which a new branch is created from.
  returned: success
  sample: master
  type: str
is_default:
  description: Whether or not the branch is set as the default one.
  returned: success
  sample: false
  type: boolean
json:
  contains:
    displayId:
      description: Branch display ID.
      returned: success
      sample: feature/mybranch
      type: str
    id:
      description: Branch ID.
      returned: success
      sample: refs/heads/feature/mybranch
      type: str
    isDefault:
      description: Whether or not the branche is default.
      returned: success
      sample: false
      type: bool
    latestChangeset:
      description: Latest Changeset id.
      returned: success
      sample: 93b84625d75123b7f7942fd72225400fa66d62ec
      type: str
    latestCommit:
      description: Latest Commit id.
      returned: success
      sample: 93b84625d75123b7f7942fd72225400fa66d62ec
      type: str
    type:
      description: Branch type.
      returned: success
      sample: BRANCH
      type: str
  description: Details of a new branch.
  returned: success
  type: dict
project_key:
  description: Bitbucket project key.
  returned: always
  sample: FOO
  type: str
repository:
  description: Bitbucket repository name.
  returned: always
  sample: bar
  type: str
state:
  description: Branch state, either I(present) or I(absent).
  returned: success
  sample: present
  type: str