Prefect integrations for working with Bitbucket repositories.
Project description
prefect-bitbucket
Welcome!
Prefect integrations for working with Bitbucket repositories.
Getting Started
Python setup
Requires an installation of Python 3.7+.
We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the Prefect documentation.
Installation
Install prefect-bitbucket
with pip
:
pip install prefect-bitbucket
Then, register to view the block on Prefect Cloud:
prefect block register -m prefect_bitbucket
Note, to use the load
method on Blocks, you must already have a block document saved through code or saved through the UI.
Write and run a flow
Load a pre-existing BitBucketCredentials block
from prefect import flow
from prefect_bitbucket.credentials import BitBucketCredentials
@flow
def use_stored_bitbucket_creds_flow():
bitbucket_credentials_block = BitBucketCredentials.load("BLOCK_NAME")
return bitbucket_credentials_block
use_stored_bitbucket_creds_flow()
Create a new BitBucketCredentials block in a flow
from prefect import flow
from prefect_bitbucket.credentials import BitBucketCredentials
@flow
def create_new_bitbucket_creds_flow():
bitbucket_credentials_block = BitBucketCredentials(
token="my-token",
username="my-username"
)
create_new_bitbucket_creds_flow()
Create a BitBucketRepository block for a public repo
from prefect_bitbucket import BitBucketRepository
public_repo = "https://bitbucket.org/my-workspace/my-repository.git"
# Creates a public BitBucket repository BitBucketRepository block
public_bitbucket_block = BitBucketRepository(
repository=public_repo
)
# Saves the BitBucketRepository block to your Prefect workspace (in the Blocks tab)
public_bitbucket_block.save("my-bitbucket-block")
Create a BitBucketRepository block for a public repo at a specific branch or tag
from prefect_bitbucket import BitBucketRepository
public_repo = "https://bitbucket.org/my-workspace/my-repository.git"
# Creates a public BitBucket repository BitBucketRepository block
branch_bitbucket_block = BitBucketRepository(
reference="my-branch-or-tag", # e.g "master"
repository=public_repo
)
# Saves the BitBucketRepository block to your Prefect workspace (in the Blocks tab)
branch_bitbucket_block.save("my-bitbucket-branch-block")
Create a new BitBucketCredentials block and a BitBucketRepository block for a private repo
from prefect_bitbucket import BitBucketCredentials, BitBucketRepository
# For a private repo, we need credentials to access it
bitbucket_credentials_block = BitBucketCredentials(
token="my-token",
username="my-username" # optional
)
# Saves the BitBucketCredentials block to your Prefect workspace (in the Blocks tab)
bitbucket_credentials_block.save(name="my-bitbucket-credentials-block")
# Creates a private BitBucket repository BitBucketRepository block
private_repo = "https://bitbucket.org/my-workspace/my-repository.git"
private_bitbucket_block = BitBucketRepository(
repository=private_repo,
bitbucket_credentials=bitbucket_credentials_block
)
# Saves the BitBucketRepository block to your Prefect workspace (in the Blocks tab)
private_bitbucket_block.save(name="my-private-bitbucket-block")
Use a preexisting BitBucketCredentials block to create a BitBucketRepository block for a private repo
from prefect_bitbucket import BitBucketCredentials, BitBucketRepository
# Loads a preexisting BitBucketCredentials block
BitBucketCredentials.load("my-bitbucket-credentials-block")
# Creates a private BitBucket repository BitBucketRepository block
private_repo = "https://bitbucket.org/my-workspace/my-repository.git"
private_bitbucket_block = BitBucketRepository(
repository=private_repo,
bitbucket_credentials=bitbucket_credentials_block
)
# Saves the BitBucketRepository block to your Prefect workspace (in the Blocks tab)
private_bitbucket_block.save(name="my-private-bitbucket-block")
!!! info "Differences between Bitbucket Server and Bitbucket Cloud"
For Bitbucket Cloud, only set the `token` to authenticate. For Bitbucket Server, set both the `token` and the `username`.
Resources
If you encounter any bugs while using prefect-bitbucket
, feel free to open an issue in the prefect-bitbucket repository.
If you have any questions or issues while using prefect-bitbucket
, you can find help in either the Prefect Discourse forum or the Prefect Slack community.
Feel free to ⭐️ or watch prefect-bitbucket
for updates too!
Development
If you'd like to install a version of prefect-bitbucket
for development, clone the repository and perform an editable install with pip
:
git clone https://github.com/PrefectHQ/prefect-bitbucket.git
cd prefect-bitbucket/
pip install -e ".[dev]"
# Install linting pre-commit hooks
pre-commit install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for prefect_bitbucket-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db6f5448fa796afd1e5af5c052289650e550bb2b7e5cee3261e4bd7e61768212 |
|
MD5 | 48c9cbde2c0371e2d55baa63aa03fe4c |
|
BLAKE2b-256 | 3de8bb6e66a58dc52222b5ca25e071e924c534d9f88dec4906c82cc2c5e114a3 |