You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	Full scan if last incremental scan failed (#4207)
Co-authored-by: thtri <thanh.hai.trinh@sap.com>
This commit is contained in:
		| @@ -316,6 +316,9 @@ func uploadAndScan(ctx context.Context, config checkmarxExecuteScanOptions, sys | ||||
| 			incremental = false | ||||
| 		} else if incremental && config.FullScansScheduled && fullScanCycle > 0 && (getNumCoherentIncrementalScans(previousScans)+1)%fullScanCycle == 0 { | ||||
| 			incremental = false | ||||
| 		} else if incremental && isLastScanFailedIncremental(previousScans) { // if the last incremental scan failed, trigger a full scan instead | ||||
| 			incremental = false | ||||
| 			log.Entry().Infof("Last incremental scan for project %v failed, triggering full scan instead", project.Name) | ||||
| 		} | ||||
|  | ||||
| 		return triggerScan(ctx, config, sys, project, incremental, influx, utils) | ||||
| @@ -323,6 +326,19 @@ func uploadAndScan(ctx context.Context, config checkmarxExecuteScanOptions, sys | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func isLastScanFailedIncremental(scans []checkmarx.ScanStatus) bool { | ||||
| 	if len(scans) == 0 { | ||||
| 		return false | ||||
| 	} | ||||
|  | ||||
| 	scan := scans[0] | ||||
| 	if scan.IsIncremental && scan.Status.Name == "Failed" { | ||||
| 		return true | ||||
| 	} else { | ||||
| 		return false | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func triggerScan(ctx context.Context, config checkmarxExecuteScanOptions, sys checkmarx.System, project checkmarx.Project, incremental bool, influx *checkmarxExecuteScanInflux, utils checkmarxExecuteScanUtils) error { | ||||
| 	scan, err := sys.ScanProject(project.ID, incremental, true, !config.AvoidDuplicateProjectScans) | ||||
| 	if err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user