jenkins-lib

Jenkins shared library
git clone https://git.in0rdr.ch/jenkins-lib.git
Log | Files | Refs | Pull requests |Archive | README

commit b8d854d1d2dd26c206f3663aa0456ebaa54c42cb
parent 843d1756063f76f8feab39dcca28aff851b659d1
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Thu, 14 Aug 2025 07:57:46 +0200

feat(packer): add naive packer build

Diffstat:
Asrc/PackerBuild.groovy | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/PackerBuild.groovy b/src/PackerBuild.groovy @@ -0,0 +1,27 @@ +// A class to describe the packer build stage +class PackerBuild implements Serializable { + private final Script script + + PackerBuild(Script script) { + this.script = script + } + + // Build with named buildArgs (first) + // Mandatory: Build template + // Optional: PACKER_LOG + void execute(Map buildVars = [], + String buildTemplate, + String packerLog = '0', // PACKER_LOG + String stageName = 'build') { + + def varList = buildVars.collect{ k, v -> "-var '${k}=${v}'" }.join(' ') + def shCmd = sprintf( + '%s packer build %s %s', + packerLog, varList, buildTemplate, argList) + + script.stage(stageName) { + script.echo "Building from template ${buildTemplate}..." + script.sh shCmd + } + } +}