Use Git Hash in CI

Get short SHA ID and use it in a CI Process

Get the short SHA ID

Add the following variable to your script:

${{CF_SHORT_REVISION}} 

Use the SHA ID in a tag

tag: ${{CF_SHORT_REVISION}} 

YAML example

step-name:
  type: build
  description: Free text description
  working-directory: ${{clone-step-name}}
  dockerfile: path/to/Dockerfile
  image-name: owner/new-image-name
  tag: ${{CF_SHORT_REVISION}}
  build-arguments:
    - key=value
  fail-fast: false 

Result in hub.docker

SHA ID in Docker Hub

SHA ID in Docker Hub

Result in Codefresh

SHA ID in Codefresh

SHA ID in Codefresh

CI/CD pipeline examples
Codefresh YAML for pipeline definitions
Creating pipelines
How Codefresh pipelines work