Add Hyper-V to CI

This commit is contained in:
Greg Hellings
2023-12-20 04:36:11 +00:00
parent a7217e9716
commit ffab1afbbe
4 changed files with 56 additions and 23 deletions
+37 -17
View File
@@ -11,28 +11,32 @@ stages:
- pipeline: $PARENT_PIPELINE_ID
job: distros
artifacts: true
- pipeline: $PARENT_PIPELINE_ID
job: generate
artifacts: true
tags:
- ${tag}
script: |
set -exo pipefail
export PACKER_LOG=1
if [ -f "${distro}.sh" ]; then
./"${distro}.sh"
fi
packer init sources
packer build "${only}" \
-var-file="${distro}" \
-var "build=${BUILD}" \
-var "cpus=2" \
-var "memory=4096" \
-var "http_port_min=${HTTP_PORT_MIN:-8000}" \
-var "http_port_max=${HTTP_PORT_MAX:-9000}" \
-except=upload \
sources
variables: &variables
PACKER_LOG: 1
COMMAND: >
packer build ${only}
-var-file="${distro}"
-var build=${BUILD}
-var cpus=2
-var memory=4096
-except=upload
sources
before_script:
- packer init sources
- echo $COMMAND
script:
- echo $COMMAND > build.sh
- bash build.sh
qemu.amd64:
extends: .build
variables:
<<: *variables
only: "-only=qemu.amd64"
tag: qemu
parallel:
@@ -41,7 +45,23 @@ qemu.amd64:
virtualbox-iso.amd64:
extends: .build
variables:
only: "-only=virtualbox-iso.amd64"
<<: *variables
only: '-only="virtualbox-iso.amd64"'
tag: vbox
parallel:
matrix: []
hyperv-iso.amd64:
extends: .build
variables:
<<: *variables
only: '-only="hyperv-iso.amd64"'
tag: hyperv
parallel:
matrix: []
cache:
paths:
- C:\Users\gregh\AppData\Roaming\packer.d\plugins\
script:
- echo $env:COMMAND > build.ps1
- powershell .\build.ps1
+15 -6
View File
@@ -1,20 +1,29 @@
stages:
- generate
- lint
- trigger
generate:
stage: generate
artifacts:
paths:
- distros/**/*.pkrvars.hcl
script: |-
for vars in $(find distros/ -name '*.pkrvars.hcl.sh'); do
"./${vars}"
done
validate:
stage: lint
needs:
- generate
cache:
paths:
- /var/lib/gitlab-runner/.config/packer/plugins/
script: |-
set -exo pipefail
packer init sources
for vars in $(find distros/ -name '*.pkrvars.hcl*'); do
if [[ "${vars}" == *.sh ]]; then
"./${vars}"
vars=${vars%.sh}
fi
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
packer validate -except=upload -var-file=${vars} sources/
done
@@ -25,7 +34,7 @@ shell:
shellcheck $(find . -name '*.sh')
distros:
stage: lint
stage: generate
artifacts:
reports:
dotenv: build.env
+2
View File
@@ -16,3 +16,5 @@ rawhide:
provider: hyperv-iso
- arch: amd64
provider: virtualbox-iso
- arch: amd64
provider: vmware-iso
+2
View File
@@ -12,4 +12,6 @@ class Provider:
return "qemu"
elif self.name.startswith("virtualbox"):
return "virtualbox"
elif self.name.startswith("hyperv"):
return "hyperv"
return None