Tomás Rossetti
09/02/2025, 9:26 PMprefect.deployments.steps.git_clone
, which points at the project's main branch. How can I modify my yaml file so that I can trigger jobs that point at another, custom, branch?Marvin
09/02/2025, 9:26 PMMarvin
09/02/2025, 9:33 PMgit_clone
step’s branch
(or commit_sha
) from an environment variable, then pass that env var as a job variable when you trigger the run.
Here’s how to update your `prefect.yaml`:
- Template the branch with an env var, falling back to main if it’s not set.
- You can also add an optional commit_sha
if you want to pin to a specific commit instead of a branch.
Example snippet:
deployments:
- name: my-deployment
entrypoint: flows/my_flow.py:my_flow
pull:
- prefect.deployments.steps.git_clone:
repository: <https://github.com/your-org/your-repo.git>
branch: "{{ env.GIT_BRANCH | default('main') }}"
# Or pin by commit instead of branch:
# commit_sha: "{{ env.GIT_SHA }}"
work_pool:
name: your-work-pool
Then, when you want to run against a different branch, pass the env var via job variables at run time:
prefect deployments run "my_flow/my-deployment" --job-variable 'env={"GIT_BRANCH":"feature/my-branch"}' --watch
Notes:
- --job-variable
values are JSON; keep the quoting as shown.
- Only set one of branch
or commit_sha
at a time.
- You can also fix branches by defining multiple deployments in the same prefect.yaml
(one per branch), if you prefer named, static deployments.
References:
- Git clone step parameters (supports branch
and commit_sha
): prefect.deployments.steps.git_clone
- Prefect YAML and templating basics: prefect.yaml guide