esp.bitbucket.bitbucket_copy (1.4.1) — module

Copy files to Bitbucket Server

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

Authors: Krzysztof Lewandowski (@klewan)

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

The C(bitbucket_copy) module copies (pushes) a file from the local machine to a Bitbucket Server repository.

Creates the file if it does not exist.

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: Copy file to Bitbucket
  esp.bitbucket.bitbucket_copy:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    src: /tmp/baz.yml
    dest: path/to/baz.yml
    message: File updated using bitbucket_copy module
    branch: master
    validate_certs: no
    force_basic_auth: yes
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Copy file to Bitbucket using inline content
  esp.bitbucket.bitbucket_copy:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    content: '# Hello world'
    dest: path/to/baz.yml
    message: File updated using bitbucket_copy module
    branch: master
    validate_certs: no
    force_basic_auth: yes

Inputs

    
src:
    description:
    - Local path to a file to copy to the Bitbucket Server repository.
    - This can be absolute or relative.
    - Required when U(content) is not provided.
    required: false
    type: path

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

dest:
    description:
    - Path in Bitbucket repositorywhere the file should be copied to.
    required: true
    type: path

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

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

branch:
    description:
    - The branch to write a file at.
    - If not specified the default branch will be used instead.
    required: false
    type: str

content:
    description:
    - When used instead of C(src), sets the contents of a file directly to the specified
      value.
    - Required when U(src) is not provided.
    required: false
    type: str

message:
    description:
    - Commit message.
    - If not specified the default message should be used.
    required: false
    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

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

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

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: Branch name.
  returned: always
  sample: master
  type: str
dest:
  description: Path in Bitbucket repositorywhere the file was copied to.
  returned: always
  sample: path/to/baz.yml
  type: str
json:
  contains:
    author:
      description: Commit request author.
      returned: success
      sample:
        active: true
        displayName: John Smith
        emailAddress: john.smith@example.com
        id: 5719
        links:
          self:
          - href: https://bitbucket.example.com/users/jsmith
        name: jsmith
        slug: jsmith
        type: NORMAL
      type: dict
    authorTimestamp:
      description: Timestamp.
      returned: success
      sample: 1618819213000
      type: int
    committer:
      description: Committer.
      returned: success
      sample:
        active: true
        displayName: John Smith
        emailAddress: john.smith@example.com
        id: 5719
        links:
          self:
          - href: https://bitbucket.example.com/users/jsmith
        name: jsmith
        slug: jsmith
        type: NORMAL
      type: dict
    committerTimestamp:
      description: Timestamp.
      returned: success
      sample: 1618819213000
      type: int
    displayId:
      description: Commit id.
      returned: success
      sample: 2525b8cc320
      type: str
    id:
      description: Commit id.
      returned: success
      sample: 2525b8cc320c6c5c71a84d1c21f0554b012214df
      type: str
    message:
      description: Commit message.
      returned: success
      sample: File updated using bitbucket_copy module
      type: str
  description: Dictionary with updated file details.
  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
src:
  description: Local path to a file which was copied to the Bitbucket Server repository.
  returned: success
  sample: /tmp/baz.yml
  type: str