Getting Started
Prerequisites
Install prefect-gitlab
Install or update to the latest version of the prefect-gitlab library and dependencies.Register newly installed block types
Register the block types in the prefect-gitlab module to make them available for use.Examples
In the examples below, you create blocks with Python code. Alternatively, blocks can be created through the Prefect UI.Store deployment flow code in a private GitLab repository
To create a deployment where the flow code is stored in a private GitLab repository, you can use theGitLabCredentials
block.
A deployment can use flow code stored in a GitLab repository without using this library in either of the following cases:
- The repository is public
- The deployment uses a Secret block to store the token
Access flow code stored in a private GitLab repository in a deployment
Use the credentials block you created above to pass the GitLab access token during deployment creation. The code below assumes there’s flow code in your private GitLab repository.prefect.yaml
file to create the deployment, reference the GitLab Credentials block in the pull
step:
Interact with a GitLab repository
The code below shows how to reference a particular branch or tag of a GitLab repository.access_token
field if the repository is public and exclude the reference
field to use the default branch.
Use the newly created block to interact with the GitLab repository.
For example, download the repository contents with the .get_directory()
method like this: