From 9354697525e9f97156e0723a3e3a308bb92014d2 Mon Sep 17 00:00:00 2001 From: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com> Date: Thu, 1 Oct 2020 17:08:07 +0200 Subject: [PATCH] fix : allow creation of Checkmarx projects (#2106) --- cmd/checkmarxExecuteScan.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/checkmarxExecuteScan.go b/cmd/checkmarxExecuteScan.go index 513fb55cd..2abb63f5e 100644 --- a/cmd/checkmarxExecuteScan.go +++ b/cmd/checkmarxExecuteScan.go @@ -43,7 +43,7 @@ func runScan(config checkmarxExecuteScanOptions, sys checkmarx.System, workspace } project, projectName, err := loadExistingProject(sys, config.ProjectName, config.PullRequestName, team.ID) if err != nil { - return errors.Wrap(err, "failed to load existing project") + return errors.Wrap(err, "error when trying to load project") } if project.Name == projectName { log.Entry().Infof("Project %v exists...", projectName) @@ -92,8 +92,11 @@ func loadExistingProject(sys checkmarx.System, initialProjectName, pullRequestNa projects, err := sys.GetProjectsByNameAndTeam(projectName, teamID) if err != nil || len(projects) == 0 { projects, err = sys.GetProjectsByNameAndTeam(initialProjectName, teamID) - if err != nil || len(projects) == 0 { - return project, projectName, errors.Wrap(err, "no projects found") + if err != nil { + return project, projectName, errors.Wrap(err, "failed getting projects") + } + if len(projects) == 0 { + return checkmarx.Project{}, projectName, nil } branchProject, err := sys.GetProjectByID(sys.CreateBranch(projects[0].ID, projectName)) if err != nil {