Skip to content

Commit

Permalink
Handle null references; #136
Browse files Browse the repository at this point in the history
  • Loading branch information
robertauer committed Nov 20, 2024
1 parent 8cc5d40 commit cc9b3e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/com/cloudogu/ces/cesbuildlib/Docker.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class Docker implements Serializable {
def userName = sh.returnStdOut('whoami')
String jenkinsUserFromEtcPasswd = sh.returnStdOut "cat /etc/passwd | grep $userName"

if (jenkinsUserFromEtcPasswd.isEmpty()) {
if (jenkinsUserFromEtcPasswd == null || jenkinsUserFromEtcPasswd.isEmpty()) {
script.error 'Unable to parse user jenkins from /etc/passwd.'
}
return jenkinsUserFromEtcPasswd
Expand Down
2 changes: 1 addition & 1 deletion src/com/cloudogu/ces/cesbuildlib/Sh.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Sh implements Serializable {
// Trim to remove trailing line breaks, which result in unwanted behavior in Jenkinsfiles:
// E.g. when using output in other sh() calls leading to executing the sh command after the line breaks,
// possibly discarding additional arguments
.trim()
?.trim()
}
}

0 comments on commit cc9b3e6

Please sign in to comment.