forked from ethanmdavidson/packer-plugin-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit.pkr.hcl
33 lines (29 loc) · 984 Bytes
/
commit.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
packer {}
data "git-commit" "test" {}
locals {
hash = data.git-commit.test.hash
# if message contains a single quote, it will mess up the echo command
message = replace(data.git-commit.test.message, "'", "")
branchesString = join(",", sort(data.git-commit.test.branches))
}
source "null" "git-plugin-test-commit" {
communicator = "none"
}
build {
sources = [
"source.null.git-plugin-test-commit",
]
provisioner "shell-local" {
inline = [
"echo 'hash: ${local.hash}'",
"echo 'branches: ${local.branchesString}'",
"echo 'author: ${data.git-commit.test.author}'",
"echo 'committer: ${data.git-commit.test.committer}'",
"echo 'timestamp: ${data.git-commit.test.timestamp}'",
"echo 'pgp_signature: ${data.git-commit.test.pgp_signature}'",
"echo 'message: ${local.message}'",
"echo 'tree_hash: ${data.git-commit.test.tree_hash}'",
"echo 'first_parent: ${data.git-commit.test.parent_hashes[0]}'",
]
}
}