esp.bitbucket.bitbucket_push (1.4.1) — module

Commit and push changes to the remote repository

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

Authors: Pawel Smolarz (pawel.smolarz@nordea.com), 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

Pushes changes to remote Bitbucket repository.

Optionally, before pushing changes, it creates a new commit containing the current contents of the index and the working tree.

Returns the commit hash.

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: Commit and push changes to the remote repository
  esp.bitbucket.bitbucket_push:
    url: 'https://bitbucket.example.com'
    username: jsmith
    password: secrect
    repository: bar
    project_key: FOO
    path: /tmp/bar  
    commit: yes  
    msg: New commit message
    committer:
      name: jsmith
      email: jsmith@example.com
    tag: '0.3.1'
    delete: no
    validate_certs: no
  register: _result

Inputs

    
msg:
    description:
    - Log message describing the changes.
    required: true
    type: str

tag:
    description:
    - Opitionally add a tag to the commit.
    required: false
    type: str

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

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

commit:
    default: true
    description:
    - Commit changes before pushing to the remove repository.
    type: bool

delete:
    default: false
    description:
    - Delete local repository after push to remote.
    type: bool

repodir:
    aliases:
    - path
    description:
    - Repository directory.
    - This must be a valid git repository.
    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

committer:
    description:
    - A person who commits the code.
    required: true
    suboptions:
      email:
        description:
        - The committer email address.
        required: true
        type: str
      name:
        description:
        - The committer username.
        required: true
        type: str
    type: dict

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:
    aliases:
    - path
    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

changed:
  description: Whether or not changes were pushed to a remote repository.
  returned: success
  sample: true
  type: bool
json:
  contains:
    after_commit_hexsha:
      description: New commit hash. Exposed only when changes were actually committed,
        i.e. when C(changed=true).
      returned: success
      sample: 06bdcc6594831af4fe869b87643efc609d7cd994
      type: str
    author:
      description: Commit request author.
      returned: success
      sample:
        email: john.smith@example.com
        name: jsmith
      type: dict
    before_commit_hexsha:
      description: A commit hash of the working tree before changes were committed.
      returned: success
      sample: c1bd91851a8f5b2b147d252ba674329773e7f675
      type: str
    committer:
      description: Committer.
      returned: success
      sample:
        email: john.smith@example.com
        name: jsmith
      type: dict
    deleted:
      description: Whether the local repository was deleted after push to remote.
      returned: success
      sample: false
      type: bool
    msg:
      description: Commit message.
      returned: success
      sample: Commit message
      type: str
    tag:
      description: Commit tag.
      returned: success
      sample: 0.3.1
      type: str
  description: Dictionary with change details.
  returned: success
  type: dict