Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1690,31 +1690,29 @@ func jobsToJobPreviews(jobs []*commonmodels.JobTask, context map[string]string,
continue
}
}
if spec.LinkURL == "" {
if sonarURL != "" {
projectKey := ""
projectScanningOutputKey := jobspec.GetJobOutputKey(job.Key, setting.WorkflowScanningJobOutputKeyProject)
projectScanningOutputKey = workflowcontroller.GetContextKey(projectScanningOutputKey)
if context[projectScanningOutputKey] != "" {
projectKey = context[projectScanningOutputKey]
}
if sonarURL != "" {
projectKey := ""
projectScanningOutputKey := jobspec.GetJobOutputKey(job.Key, setting.WorkflowScanningJobOutputKeyProject)
projectScanningOutputKey = workflowcontroller.GetContextKey(projectScanningOutputKey)
if context[projectScanningOutputKey] != "" {
projectKey = context[projectScanningOutputKey]
}

branch := ""
branchScanningOutputKey := jobspec.GetJobOutputKey(job.Key, setting.WorkflowScanningJobOutputKeyBranch)
branchScanningOutputKey = workflowcontroller.GetContextKey(branchScanningOutputKey)
if context[branchScanningOutputKey] != "" {
branch = context[branchScanningOutputKey]
}
branch := ""
branchScanningOutputKey := jobspec.GetJobOutputKey(job.Key, setting.WorkflowScanningJobOutputKeyBranch)
branchScanningOutputKey = workflowcontroller.GetContextKey(branchScanningOutputKey)
if context[branchScanningOutputKey] != "" {
branch = context[branchScanningOutputKey]
}

resultAddr, err := sonar.GetSonarAddress(sonarURL, projectKey, branch)
if err != nil {
log.Errorf("failed to get sonar address with project key %s, error: %v", projectKey, err)
continue
}
spec.LinkURL = resultAddr
} else {
log.Errorf("failed to get sonar url from job task's env")
resultAddr, err := sonar.GetSonarAddress(sonarURL, projectKey, branch)
if err != nil {
log.Errorf("failed to get sonar address with project key %s, error: %v", projectKey, err)
continue
}
spec.LinkURL = resultAddr
} else {
log.Errorf("failed to get sonar url from job task's env")
}
jobPreview.Spec = spec
case string(config.JobZadigDeploy):
Expand Down