June 20-22 Announcing HashiConf Europe full schedule: keynotes, sessions, labs & more Register Now
  • Infrastructure
    • terraform
    • packer
  • Networking
    • consul
  • Security
    • vault
    • boundary
  • Applications
    • nomad
    • waypoint
    • vagrant
  • HashiCorp Cloud Platform

    A fully managed platform to automate infrastructure on any cloud with HashiCorp products.

    • consul
    • terraform
    • vault
    • packerbeta
    Visit cloud.hashicorp.com
  • Overview
  • Tutorials
  • Docs
  • Plugins
  • Community
GitHubInstall PackerTry HCP Packer
  • About External Plugins

      • 1&1
      • Alicloud ECS
      • Alicloud Import
      • Anka Registry Push
      • VM Clone
      • VM Create
      • Ansible (Remote)
      • Ansible Local
      • Overview
      • Amazon AMI
      • Parameter Store
      • Secrets Manager
      • Overview
      • chroot
      • EBS
      • EBS Surrogate
      • EBS Volume
      • Instance
      • Amazon Import
      • Overview
      • ARM
      • chroot
      • DTL
      • Azure DTL Artifact
      • Chef Client
      • Chef Solo
      • CloudStack
      • Converge
      • digitalocean
      • digitalocean-import
      • Docker
      • Docker Import
      • Docker Push
      • Docker Save
      • Docker Tag
      • Overview
      • Commit
      • Repository
      • Tree
      • Google Cloud Platform
      • googlecompute-export
      • googlecompute-import
      • Overview
      • Receipt
      • Overview
      • Toppings
      • Overview
      • Coffees
      • Ingredients
      • Overview
      • Order
      • Hetzner Cloud
      • HuaweiCloud
      • HyperOne
      • Overview
      • ISO
      • VMCX
      • InSpec
      • JDCloud
      • Kamatera
      • Linode
      • LXC
      • LXD
      • Naver Cloud
      • OpenStack
      • Overview
      • Classic
      • OCI
      • Overview
      • BSU
      • BSU Surrogate
      • BSU Volume
      • chroot
      • Overview
      • ISO
      • PVM
      • ProfitBricks
      • Overview
      • Clone
      • ISO
      • Puppet Masterless
      • Puppet Server
      • QEMU
      • Salt Masterless
      • Scaleway
      • SSH Key
      • Tencent Cloud
      • Triton
      • UCloud
      • UCloud Import
      • upcloud
      • Vagrant
      • Vagrant
      • Vagrant Cloud
      • Overview
      • ISO
      • OVF
      • VM
      • Overview
      • Clone
      • ISO
      • vSphere
      • vSphere Template
      • Overview
      • ISO
      • VMX
      • Vultr
      • Yandex
      • yandex-export
      • yandex-import
Type '/' to Search
Community
v0.3.1

»Commit

Type: git-commit

The commit data source is used to fetch information about a specific commit. It needs to be run inside an existing git repo.

»Required

There are no required configuration fields.

»Optional

  • path (string) - The path to a directory inside your git repo. The plugin will search for a git repo, starting in this directory and walking up through parent directories. Defaults to '.' (the directory packer was executed in).

  • commit_ish (string) - A Commit-Ish value. (e.g. tag) pointing to the target commit object. See go-git ResolveRevision for the list of supported values. Defaults to 'HEAD'.

»Output

  • hash (string) - The SHA1 checksum or "hash" value of the selected commit.
  • branches (string) - The short names of branches at the selected commit.
  • author (string) - The author of the commit, in standard A U Thor <author@example.com> format.
  • committer (string) - The committer of the commit, in same format as author.
  • pgp_signature (string) - The PGP signature attached to the commit.
  • message (string) - The commit message.
  • tree_hash (string) - The hash of the root tree of the commit.
  • parent_hashes (list[string]) - The hashes of the parent commits.

»Example Usage

This example shows how a truncated commit sha can be appended to an image name, with the author in the image description.

data "git-commit" "cwd-head" { }

locals {
  truncated_sha = substr(data.git-commit.cwd-head.hash, 0, 8)
  author = data.git-commit.cwd-head.author
}

source "googlecompute" "example" {
  image_name = "image-${local.truncated_sha}"
  image_description = "Built from a commit by ${local.author}"
}

build {
  sources = ["source.googlecompute.example"]
}
data "git-commit" "cwd-head" { }

locals {
  truncated_sha = substr(data.git-commit.cwd-head.hash, 0, 8)
  author = data.git-commit.cwd-head.author
}

source "googlecompute" "example" {
  image_name = "image-${local.truncated_sha}"
  image_description = "Built from a commit by ${local.author}"
}

build {
  sources = ["source.googlecompute.example"]
}
github logoEdit this page
IntroGuidesDocsCommunityPrivacySecurityPress KitConsent Manager