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

»Repository

Type: git-repository

The repository data source is used to fetch information about a git repository. 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).

»Output

  • head (string) - The short name of HEAD's current location.
  • branches (list[string]) - The list of branches in the repository.
  • tags (list[string]) - The list of tags in the repository.
  • is_clean (bool) - true if the working tree is clean, false otherwise.

»Example Usage

This example shows how a a suffix can be added to the version number for any AMI built outside the main branch.

data "git-repository" "cwd" {}

variable version {
  type = string
}

locals {
  onMaster = data.git-repository.cwd.head == "main"
  version  = onMaster ? "${var.version}" : "${var.version}-SNAPSHOT"
}

source "amazon-ebs" "ami1" {
  ami_description = "AMI1"
  ami_name        = "ami1-${local.version}"
}
data "git-repository" "cwd" {}

variable version {
  type = string
}

locals {
  onMaster = data.git-repository.cwd.head == "main"
  version  = onMaster ? "${var.version}" : "${var.version}-SNAPSHOT"
}

source "amazon-ebs" "ami1" {
  ami_description = "AMI1"
  ami_name        = "ami1-${local.version}"
}
github logoEdit this page
IntroGuidesDocsCommunityPrivacySecurityPress KitConsent Manager