Robert Szomolanyi
09/12/2025, 9:06 AMMarvin
09/12/2025, 9:06 AMMarvin
09/12/2025, 9:24 AMpip install "prefect[gitlab]"
prefect block register -m prefect_gitlab.credentials
- Block registration makes the GitLab block type available in the UI.
- Help link: prefect-gitlab integration docs
Step 2 — Create the GitLab Credentials block in the UI
1) In the Prefect UI, go to Blocks
2) Click “+ Create block”
3) Search for “GitLab Credentials”
4) Fill the fields:
- Name: my-token
- Base URL: http://gitlab.local.com
- Access token: paste your GitLab token value (ensure it has at least read_repository scope)
5) Save
Step 3 — Use the block in prefect.yaml to pull from GitLab
This prefect.yaml uses deployment “pull” steps to:
- Load your GitLab Credentials block
- Clone your repository with those credentials
- Set the working directory to the checked-out code
- Register a deployment for a flow found in flows/my_flow.py:my_flow
Replace owner/repo with your real GitLab path.
name: gitlab-example
prefect-version: ">=3.0.0,<4.0.0"
pull:
# Load the GitLab Credentials block
- prefect.deployments.steps.pull.pull_with_block:
id: gl-creds
block_type_slug: gitlab-credentials
block_document_name: my-token
# Clone your repo using the credentials block
- prefect.deployments.steps.pull.git_clone:
id: clone
repository: "<http://gitlab.local.com/owner/repo.git>"
branch: main
credentials: "{{ gl-creds.block }}"
# If you prefer, you can pass the token directly instead:
# access_token: "{{ gl-creds.block.access_token }}"
# Set the working directory to the cloned repo so entrypoint paths resolve
- prefect.deployments.steps.pull.set_working_directory:
directory: "{{ clone.directory }}"
deployments:
- name: my-flow/my-deployment
entrypoint: "flows/my_flow.py:my_flow"
work_pool:
name: default
# optional schedules, parameters, etc.
Step 4 — Deploy
From the directory with your prefect.yaml:
prefect deploy
Notes and tips
- The git_clone step supports either credentials: <Block> or access_token: <string>. Using the block is preferred for secret management.
- Use the full Git URL including .git, e.g. http://gitlab.local.com/group/project.git
- Ensure the same packages are available in your execution environment (workers) — i.e., install prefect[gitlab] there too
- Docs for YAML and pull steps:
- prefect.yaml reference
- Store flow code for deployments
If you share your exact repo path and flow entrypoint, I can tailor the YAML to your setup precisely.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by