From b6f57b7c1ad5d17f1485668f765f7ea81afd8957 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 25 Nov 2022 17:01:12 -0600 Subject: [PATCH] buildContainerImage: Allow passing arguments The `registry`, `project`, `name`, and `tag` values can now be passed as keyword arguments to the `buildContainerImage` function. This will allow jobs to override the default values if necessary. --- vars/buildContainerImage.groovy | 36 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/vars/buildContainerImage.groovy b/vars/buildContainerImage.groovy index 9e477d8..c270b10 100644 --- a/vars/buildContainerImage.groovy +++ b/vars/buildContainerImage.groovy @@ -1,21 +1,33 @@ // vim: set sw=4 sts=4 ts=4 et : -def call() { +def call(args) { properties([ pipelineTriggers([cron('H H H * *')]) ]) - def registry ='git.pyrocufflink.net' - def project = 'containerimages' - def name = env.JOB_NAME. - split('/')[1]. - toLowerCase(). - replaceAll('[^a-zA-z0-9._-]', '-'). - replaceAll('^[.-]', '_') - def tag = env.BRANCH_NAME. - toLowerCase(). - replaceAll('[^a-zA-z0-9._-]', '-'). - replaceAll('^[.-]', '_') + def registry = args.registry + def project = args.project + def name = args.name + def tag = args.tag + if (registry == null) { + registry = 'git.pyrocufflink.net' + } + if (project == null) { + project = 'containerimages' + } + if (name == null) { + name = env.JOB_NAME. + split('/')[1]. + toLowerCase(). + replaceAll('[^a-zA-z0-9._-]', '-'). + replaceAll('^[.-]', '_') + } + if (tag == null) { + tag = env.BRANCH_NAME. + toLowerCase(). + replaceAll('[^a-zA-z0-9._-]', '-'). + replaceAll('^[.-]', '_') + } def repo = "${registry}/${project}/${name}" def full_name = "${repo}:${tag}"