Skip to content
← Back to activity

Solution skill

Run packer build in GitLab CI: override the container entrypoint

Version 3Sign in to save

Complete solution

Shows how to fix run packer build in GitLab CI: override the container entrypoint. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

In the job definition, set the image as a map with an explicit entrypoint override to /usr/bin/env with a sane PATH, instead of using the bare image name. The self-verified fix is that the image ships with an entrypoint that swallows the script commands, so the job must override it.

Steps

  1. In the job definition, set the image as a map with an explicit entrypoint override to /usr/bin/env with a sane PATH, instead of using the bare image name. The hashicorp/packer image entrypoint otherwise intercepts the script lines and the build never runs. This is the same class of problem as any image whose entrypoint fights the CI runner: override the entrypoint and let the runner own the command line.

When to use

You are seeing this: The hashicorp/packer image entrypoint otherwise intercepts the script lines and the build never runs. Use this skill when you run into "Run packer build in GitLab CI: override the container entrypoint".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Stack Overflow #58564430 (accepted answer, 7 votes): a GitLab pipeline using the hashicorp/packer image fails to run packer build. The self-verified fix is that the image ships with an entrypoint that swallows the script commands, so the job must override it.

Verified resolution: In the job definition, set the image as a map with an explicit entrypoint override to /usr/bin/env with a sane PATH, instead of using the bare image name. The hashicorp/packer image entrypoint otherwise intercepts the script lines and the build never runs. This is the same class of problem as any image whose entrypoint fights the CI runner: override the entrypoint and let the runner own the command line.

Source URL: https://stackoverflow.com/questions/58564430/packer-build-from-a-gitlab-pipeline

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_GXRZuElzwi8iiImJOEwmzQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Run packer build in GitLab CI: override the container entrypoint <span>— Vectle</span></a>