hashicorp / hashicorp/packer

PACKER_BUILD_NAME environment var is not populated with expected value

Open
#12,482 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

#### Overview of the Issue

PACKER_BUILD_NAME gets populated with the original source name, despite the source name being overridden.

#### Reproduction Steps

Given the template below, I would expect
PACKER_BUILD_NAME=workshop
However, what I'm actually seeing is
PACKER_BUILD_NAME=source1

Note that the 'only' attribute using the re-named name works as expected. In addition, the packer log output also uses the re-named name. Hence why I would think the env variable would have the same name in it. Apologies if this is working as expected but the behavior seems mismatched to me, and the documentation isn't terribly clear.

The MY_PACKER_BUILD_NAME I'm using as a workaround, for reference.

### Packer version

1.9.1

### Simplified Packer Template

source "amazon-ebs" "source1" {
...
}

build {

source "source.amazon-ebs.source1" {
name = "workshop"
}

provisioner "powershell" {
only = ["amazon-ebs.workshop"]
environment_vars = ["MY_PACKER_BUILD_NAME=${source.name}"]
script = "..."
}

}

### Operating system and Environment details

running packer on debian x64 against windowd 2019 x64 on aws

### Log Fragments and crash.log files

amazon-ebs.workshop: PACKER_BUILD_NAME is source1
amazon-ebs.workshop: MY_PACKER_BUILD_NAME is workshop

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.