-
Notifications
You must be signed in to change notification settings - Fork 318
/
build-ci.tmpl
59 lines (50 loc) · 2.62 KB
/
build-ci.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright 2023-2024 Broadcom. All rights reserved.
# SPDX-License-Identifier: BSD-2
##############################################################################
##
## Auto-generated .gitlab-ci.yml for building Packer Example for vSphere
##
## Do not modify this file directly, either:
##
## - modify the source build.yaml
## - modify the template build-ci.tmpl
##
## then run the following command to re-create the .gitlab-ci.yml file:
##
## gomplate -c build.yaml -f build-ci.tmpl -o .gitlab-ci.yml
##
##############################################################################
variables:
SCRIPT_PATH: "${CI_PROJECT_DIR}"
CONFIG_PATH: "${CI_PROJECT_DIR}/config"
INPUT_PATH: ""
BUILD_VARS: ""
EXTRA_VAR_FILES: ""
BUILD_ONLY: ""
##############################################################################
.packer-build:
stage: build
#tags:
# - packer
before_script:
- "packer init \"$INPUT_PATH\""
- "packer validate -var-file=\"$CONFIG_PATH/vsphere.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/build.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/ansible.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/proxy.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/common.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/$BUILD_VARS\" ${EXTRA_VAR_FILES} \"$INPUT_PATH\""
script:
- "packer build -force -on-error=ask -var-file=\"$CONFIG_PATH/vsphere.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/build.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/ansible.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/proxy.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/common.pkrvars.hcl\" -var-file=\"$CONFIG_PATH/$BUILD_VARS\" ${EXTRA_VAR_FILES} ${BUILD_ONLY} \"$INPUT_PATH\""
when: manual
##############################################################################
{{ range $menu := (ds "build").menu -}}
{{ range $submenu := $menu.submenu -}}
{{ $submenu.entry | strings.ReplaceAll " (cloud-init)" "" | strings.ReplaceAll " " "-" | strings.ReplaceAll "---" "-" }}:
extends: .packer-build
variables:
INPUT_PATH: "$SCRIPT_PATH/{{ $submenu.build.path }}"
BUILD_VARS: "{{ $submenu.build.path | strings.ReplaceAll "builds" "" | strings.TrimPrefix "/" | strings.TrimSuffix "/" | strings.ReplaceAll "/" "-" }}.pkrvars.hcl"
{{- if (coll.Has $submenu.build "only") }}
BUILD_ONLY: "--only {{ join $submenu.build.only "," }}"
{{- end -}}
{{- if (coll.Has $submenu.build "var_files") }}
EXTRA_VAR_FILES: "{{ range $index, $value := $submenu.build.var_files }}{{if $index}} {{end}}-var-file=$CONFIG_PATH/{{ $value }}{{ end }}"
{{- end }}
##############################################################################
{{ end }}{{ end -}}