jenkins-lib

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

commit a0e5b03c59548ad12d03c2794c8b562d57da0695
parent 927b82ce00bb6e0b2a2d3b35a64d207f379b0cc6
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun,  9 Jun 2024 22:56:26 +0200

feat: add src class

Diffstat:
Asrc/BuildahBud.groovy | 27+++++++++++++++++++++++++++
Asrc/BuildahPush.groovy | 22++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/BuildahBud.groovy b/src/BuildahBud.groovy @@ -0,0 +1,27 @@ +// A class to describe the Buildah bud stage +// source: https://stackoverflow.com/a/53204143 +class BuildahBud { + private final Script script + + BuildahBud(Script script) { + this.script = script + } + + void execute(String imgContext, + String imgName, + String imgArch = 'arm64/v8', + String imgTag = 'latest', + String imgRegistry = 'haproxy.lan:5000', + String stageName = 'build') { + + def shCmd = sprintf( + 'buildah bud --no-cache --arch=%s -t %s/%s:%s %s', + imgArch, imgRegistry, imgName, imgTag, imgContext) + + script.stage(stageName) { + script.echo "Building image ${imgRegistry}/${imgName}:${imgTag}..." + //script.sh "printenv" + script.sh shCmd + } + } +} diff --git a/src/BuildahPush.groovy b/src/BuildahPush.groovy @@ -0,0 +1,22 @@ +// A class to describe the Buildah push stage +// source: https://stackoverflow.com/a/53204143 +class BuildahPush { + private final Script script + + BuildahPush(Script script) { + this.script = script + } + + void execute(String imgName, + String imgTag = 'latest', + String imgRegistry = 'haproxy.lan:5000', + String stageName = 'push') { + + def shCmd = sprintf('buildah push %s/%s:%s', imgRegistry, imgName, imgTag) + + script.stage(stageName) { + script.echo "Building image ${imgRegistry}/${imgName}:${imgTag}..." + script.sh shCmd + } + } +}