从Gitlab流水线构建Packer

7

我正在尝试在Gitlab流水线中执行我的packer构建,但在互联网上没有找到相关示例,不过我看到有一个Docker镜像,因此我希望这个YAML文件可以完成任务:

image: hashicorp/packer

stages:
  - build

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

但我不理解这种行为,CI拉取镜像、克隆存储库,最终结果却是这样:

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

它甚至没有打印我的 echo Hello World,并且打印了2次如何与CLI交互,为什么会出现这种情况?

1个回答

11

我找到了如何修复它,我必须更改:

image: hashicorp/packer

转化为:

image:
  name: hashicorp/packer
  entrypoint:
    - '/usr/bin/env'
    - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接