Package: prefect-bitbucket
prefect-bitbucketWelcome!Prefect integrations for working with Bitbucket repositories.Getting StartedPython setupRequires 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 thePrefect documentation.InstallationInstallprefect-bitbucketwithpip:pipinstallprefect-bitbucketThen, register toview the blockon Prefect Cloud:prefectblockregister-mprefect_bitbucketNote, to use theloadmethod on Blocks, you must already have a block documentsaved through codeorsaved through the UI.Write and run a flowLoad a pre-existing BitBucketCredentials blockfromprefectimportflowfromprefect_bitbucket.credentialsimportBitBucketCredentials@flowdefuse_stored_bitbucket_creds_flow():bitbucket_credentials_block=BitBucketCredentials.load("BLOCK_NAME")returnbitbucket_credentials_blockuse_stored_bitbucket_creds_flow()Create a new BitBucketCredentials block in a flowfromprefectimportflowfromprefect_bitbucket.credentialsimportBitBucketCredentials@flowdefcreate_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 repofromprefect_bitbucketimportBitBucketRepositorypublic_repo="https://bitbucket.org/my-workspace/my-repository.git"# Creates a public BitBucket repository BitBucketRepository blockpublic_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 tagfromprefect_bitbucketimportBitBucketRepositorypublic_repo="https://bitbucket.org/my-workspace/my-repository.git"# Creates a public BitBucket repository BitBucketRepository blockbranch_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 repofromprefect_bitbucketimportBitBucketCredentials,BitBucketRepository# For a private repo, we need credentials to access itbitbucket_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 blockprivate_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 repofromprefect_bitbucketimportBitBucketCredentials,BitBucketRepository# Loads a preexisting BitBucketCredentials blockBitBucketCredentials.load("my-bitbucket-credentials-block")# Creates a private BitBucket repository BitBucketRepository blockprivate_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`.ResourcesIf you encounter any bugs while usingprefect-bitbucket, feel free to open an issue in theprefect-bitbucketrepository.If you have any questions or issues while usingprefect-bitbucket, you can find help in either thePrefect Discourse forumor thePrefect Slack community.Feel free to ⭐️ or watchprefect-bitbucketfor updates too!DevelopmentIf you'd like to install a version ofprefect-bitbucketfor development, clone the repository and perform an editable install withpip:gitclonehttps://github.com/PrefectHQ/prefect-bitbucket.gitcdprefect-bitbucket/

pipinstall-e".[dev]"# Install linting pre-commit hookspre-commitinstall