From 356d9ecc1d15c941b07a302ca1fbadb3e254dd84 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 1 Dec 2022 20:06:59 -0600 Subject: [PATCH] buildContainerImage: Handle null arguments If the `buildContainerImage` method is called without passing any arguments at all, the `args` object will be `null`. Attempting to access the properties of it in that case raises a `NullPointerException`. Fortunately, Groovy has a `?` operator that returns `null` when the named object is `null` and avoids accessing its properties. --- vars/buildContainerImage.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vars/buildContainerImage.groovy b/vars/buildContainerImage.groovy index c46e480..511be1c 100644 --- a/vars/buildContainerImage.groovy +++ b/vars/buildContainerImage.groovy @@ -5,11 +5,11 @@ def call(args) { pipelineTriggers([cron('H H H * *')]) ]) - def registry = args.registry - def project = args.project - def name = args.name - def tag = args.tag - def arch = args.arch + def registry = args?.registry + def project = args?.project + def name = args?.name + def tag = args?.tag + def arch = args?.arch if (registry == null) { registry = 'git.pyrocufflink.net' }