Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherrypick #4019 into 3.2.0-20241212 #4024

Open
wants to merge 1 commit into
base: 3.2.0-20241212
Choose a base branch
from
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