github.com/hashicorp/packer@v1.14.3/website/content/docs/commands/build.mdx (about)

     1  ---
     2  description: |
     3    The `packer build` command builds all of the artifacts defined in a template. Builds can run in parallel or sequentially.
     4  page_title: packer build - Commands
     5  ---
     6  
     7  # `packer build` command reference
     8  
     9  <Note>
    10  
    11  Starting August 1st, 2025, the source for many official HashiCorp-maintained Packer plugins is moving from GitHub releases to the official HashiCorp release site, [releases.hashicorp.com](https://releases.hashicorp.com). Refer to [Install HashiCorp-maintained plugins](/packer/docs/plugins/install#install-hashicorp-maintained-plugins) for more information.
    12  
    13  </Note>
    14  
    15  The `packer build` command takes a template and runs all the builds within it
    16  in order to generate a set of artifacts. The various builds specified within a
    17  template are executed in parallel, unless otherwise specified. And the
    18  artifacts that are created will be outputted at the end of the build.
    19  
    20  ## Options
    21  
    22  - `-color=false` - Disables colorized output. Enabled by default.
    23  
    24  - `-debug` - Disables parallelization and enables debug mode. Debug mode
    25    flags the builders that they should output debugging information. The exact
    26    behavior of debug mode is left to the builder. In general, builders usually
    27    will stop between each step, waiting for keyboard input before continuing.
    28    This will allow the user to inspect state and so on.
    29  
    30  `@include 'commands/except.mdx'`
    31  
    32  - `-force` - Forces a builder to run when artifacts from a previous build
    33    prevent a build from running. The exact behavior of a forced build is left
    34    to the builder. In general, a builder supporting the forced build will
    35    remove the artifacts from the previous build. This will allow the user to
    36    repeat a build without having to manually clean these artifacts beforehand.
    37  
    38  - `-on-error=cleanup` (default), `-on-error=abort`, `-on-error=ask`, `-on-error=run-cleanup-provisioner` -
    39    Selects what to do when the build fails during provisioning. Please note that
    40    this only affects the build during the provisioner run, not during the
    41    post-processor run, because it is related to whether or not to keep the
    42    instance running and related artifacts like generated SSH keys on the system
    43    when a provisioner fails.
    44  
    45    - `cleanup` cleans up after the previous steps, deleting temporary files and virtual machines.
    46    - `abort` exits without any cleanup, which might require the next build to use `-force`.
    47    - `ask` presents a prompt and waits for you to decide to clean up, abort, or retry
    48      the failed step.
    49    - `run-cleanup-provisioner` aborts and exits without any cleanup besides
    50      the [error-cleanup-provisioner](/packer/docs/templates/legacy_json_templates/provisioners#on-error-provisioner) if one is defined.
    51  
    52  `@include 'commands/only.mdx'`
    53  
    54  - `-parallel-builds=N` - Limit the number of builds to run in parallel, 0
    55    means no limit (defaults to 0).
    56  
    57  - `-timestamp-ui` - Enable prefixing of each ui output with an RFC3339
    58    timestamp.
    59  
    60  - `-var` - Set a variable in your Packer template. This option can be used
    61    multiple times. This is useful for setting version numbers for your build.
    62  
    63  - `-var-file` - Set template variables from a file.
    64  
    65  - `-warn-on-undeclared-var` - Setting this flag will yield a warning for each assignment within
    66    a variable definitions file (*.pkrvars.hcl | *.pkrvars.json) that does not have an accompanying
    67    variable block. This can occur when using a var-file that contains a large amount of unused variables
    68    for a given HCL2 template. For HCL2 template builds defining a value for a variable in a var-file is
    69    not enough on its own for Packer to function, as there also needs to be a variable block definition in
    70    the template files `pkr.hcl` for the variable. By default `packer build` will not warn when a var-file
    71    contains one or more undeclared variables.