1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

Merge pull request #169 from marcusholl/pr/gitUtilsParameterSanityCheck

GitUtils: sanity check for parameters handed over via signature
This commit is contained in:
Marcus Holl 2018-06-27 09:35:06 +02:00 committed by GitHub
commit d9cdc9af42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,14 @@ String[] extractLogLines(String filter = '',
String to = 'HEAD', String to = 'HEAD',
String format = '%b') { String format = '%b') {
// Checks below: there was an value provided from outside, but the value was null.
// Throwing an exception is more transparent than making a fallback to the defaults
// used in case the paramter is omitted in the signature.
if(filter == null) throw new IllegalArgumentException('Parameter \'filter\' not provided.')
if(! from?.trim()) throw new IllegalArgumentException('Parameter \'from\' not provided.')
if(! to?.trim()) throw new IllegalArgumentException('Parameter \'to\' not provided.')
if(! format?.trim()) throw new IllegalArgumentException('Parameter \'format\' not provided.')
sh ( returnStdout: true, sh ( returnStdout: true,
script: """#!/bin/bash script: """#!/bin/bash
git log --pretty=format:${format} ${from}..${to} git log --pretty=format:${format} ${from}..${to}