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.
This commit is contained in:
@@ -5,11 +5,11 @@ def call(args) {
|
|||||||
pipelineTriggers([cron('H H H * *')])
|
pipelineTriggers([cron('H H H * *')])
|
||||||
])
|
])
|
||||||
|
|
||||||
def registry = args.registry
|
def registry = args?.registry
|
||||||
def project = args.project
|
def project = args?.project
|
||||||
def name = args.name
|
def name = args?.name
|
||||||
def tag = args.tag
|
def tag = args?.tag
|
||||||
def arch = args.arch
|
def arch = args?.arch
|
||||||
if (registry == null) {
|
if (registry == null) {
|
||||||
registry = 'git.pyrocufflink.net'
|
registry = 'git.pyrocufflink.net'
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user