从 Gitlab 管道构建 Packer

Lud*_*udo 4 packer gitlab-ci

我正在尝试将我的打包器构建执行到 Gitlab 管道中,我没有在互联网上找到示例,但我看到有一个 docker 图像,所以我希望这个 yaml 可以完成这项工作:

image: hashicorp/packer

stages:
  - build

build:
  stage: build
  script:
    - echo "Hello world"
    - packer build ./definition.json
  only:
    - master
Run Code Online (Sandbox Code Playgroud)

但我不明白这种行为,CI 拉取图像,克隆 repo,然后结果是这样的:

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
Run Code Online (Sandbox Code Playgroud)

它甚至不打印 my echo Hello World,它打印了 2 次我应该如何使用 CLI 进行迭代,为什么会出现这种行为?

Lud*_*udo 9

我找到了解决方法,我不得不改变:

image: hashicorp/packer
Run Code Online (Sandbox Code Playgroud)

进入:

image:
  name: hashicorp/packer
  entrypoint:
    - '/usr/bin/env'
    - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Run Code Online (Sandbox Code Playgroud)