<@ULVA73B9P> My commit sha is empty, what I'm forg...
# ask-marvin
l
@Marvin My commit sha is empty, what I'm forgetting to set ? PREFECT_GIT_COMMIT_SHA my prefect.yaml where im using build: - prefect_docker.deployments.steps.build_docker_image: id: build-image requires: prefect-docker>=0.6.0 image_name: "{{ prefect.blocks.secret.docker-image }}" tag: "reports-analytics-{{ $PREFECT_GIT_COMMIT_SHA }}" dockerfile: ../Dockerfile platform: "linux/amd64"
prefect rocket 1
m
thought for 224.3 seconds
Short answer:
PREFECT_GIT_COMMIT_SHA
isn’t something Prefect sets for you. If it’s empty, it just isn’t defined in the environment where you’re running
prefect deploy
. You’ve got a few ways to fix it (any one of these will work): 1) Set it before you run prefect deploy - Bash:
Copy code
export PREFECT_GIT_COMMIT_SHA=$(git rev-parse --short HEAD)
  prefect deploy
- PowerShell:
Copy code
$env:PREFECT_GIT_COMMIT_SHA = (git rev-parse --short HEAD)
  prefect deploy
2) Compute it inside your build steps and reference the step output
Copy code
build:
  - prefect.deployments.steps.run_shell_script:
      id: get-sha
      script: "git rev-parse --short HEAD"
  - prefect_docker.deployments.steps.build_docker_image:
      id: build-image
      requires: prefect-docker>=0.6.0
      image_name: "{{ prefect.blocks.secret.docker-image }}"
      tag: "reports-analytics-{{ get-sha.stdout }}"
      dockerfile: ../Dockerfile
      platform: "linux/amd64"
3) Use your CI’s built-in commit SHA variable instead - GitHub Actions:
Copy code
tag: "reports-analytics-{{ $GITHUB_SHA }}"
Or explicitly set your variable:
Copy code
- name: Deploy
    run: |
      export PREFECT_GIT_COMMIT_SHA=${{ github.sha }}
      prefect deploy
- GitLab CI:
Copy code
tag: "reports-analytics-{{ $CI_COMMIT_SHA }}"
Notes: - Build steps run in the environment where you execute
prefect deploy
. Make sure that environment has
git
installed and is inside the repo so
git rev-parse
works. - Prefect 3.x will use git metadata for deployment versioning if available, but it does not automatically populate
PREFECT_GIT_COMMIT_SHA
for templating. Docs for reference: - Prefect YAML templating and environment variables: prefect.yaml guide - Run shell script step: run_shell_script step If you can share where you’re running
prefect deploy
(local, GitHub Actions, GitLab, etc.), I can give a tailored snippet.
1