1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-11-06 09:09:19 +02:00

fix(githubCreateIssue): prevent panic for Github error (#2914)

In case the Github connection leads to an error it can happen that a nil pointer dereference exception can occur.
This is to fix this.

Co-authored-by: Sven Merk <33895725+nevskrem@users.noreply.github.com>
This commit is contained in:
Oliver Nocon
2021-06-16 22:31:01 +02:00
committed by GitHub
parent a03be973bc
commit 78d7c4c71a

View File

@@ -51,7 +51,9 @@ func runGithubCreateIssue(ctx context.Context, config *githubCreateIssueOptions,
newIssue, resp, err := ghCreateIssueService.Create(ctx, config.Owner, config.Repository, &issue)
if err != nil {
log.Entry().Errorf("GitHub response code %v", resp.Status)
if resp != nil {
log.Entry().Errorf("GitHub response code %v", resp.Status)
}
return errors.Wrap(err, "error occurred when creating issue")
}
log.Entry().Debugf("New issue created: %v", newIssue)