7

I am trying to execute my packer build into a Gitlab pipeline, i didn't find examples on the internet but i have seen there is a docker image, so i was hoping this yaml would do the job:

image: hashicorp/packer

stages:
  - build

build:
  stage: build
  script:
    - echo "Hello world"
    - packer build ./definition.json
  only:
    - master

But i don't understand the behavior, the CI pull the image, clone the repo, then it ends up like this:

Skipping Git submodules setup
Usage: packer [--version] [--help] <command> [<args>]

Available commands are:
    build       build image(s) from template
    console     creates a console for testing variable interpolation
    fix         fixes templates from old versions of packer
    inspect     see components of a template
    validate    check that a template is valid
    version     Prints the Packer version

Usage: packer [--version] [--help] <command> [<args>]

Available commands are:
    build       build image(s) from template
    console     creates a console for testing variable interpolation
    fix         fixes templates from old versions of packer
    inspect     see components of a template
    validate    check that a template is valid
    version     Prints the Packer version

ERROR: Job failed: exit code 127

It doesn't even print my echo Hello World, and it prints 2 times how i should iterract with the CLI, why this behavior?

Ludo
  • 5,060
  • 15
  • 53
  • 85

1 Answers1

11

I found how to fix it, i had to change:

image: hashicorp/packer

into:

image:
  name: hashicorp/packer
  entrypoint:
    - '/usr/bin/env'
    - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Ludo
  • 5,060
  • 15
  • 53
  • 85