8080 "webhooks" ,
8181)
8282
83+ _UNNEEDED_CONTEXT_DATA = (
84+ "sonar.announcement.message" ,
85+ "sonar.auth.github.allowUsersToSignUp" ,
86+ "sonar.auth.github.apiUrl" ,
87+ "sonar.auth.github.appId" ,
88+ "sonar.auth.github.enabled" ,
89+ "sonar.auth.github.groupsSync" ,
90+ "sonar.auth.github.organizations" ,
91+ "sonar.auth.github.webUrl" ,
92+ "sonar.builtInQualityProfiles.disableNotificationOnUpdate" ,
93+ "sonar.core.id" ,
94+ "sonar.core.serverBaseURL" ,
95+ "sonar.core.startTime" ,
96+ "sonar.dbcleaner.branchesToKeepWhenInactive" ,
97+ "sonar.forceAuthentication" ,
98+ "sonar.host.url" ,
99+ "sonar.java.jdkHome" ,
100+ "sonar.links.ci" ,
101+ "sonar.links.homepage" ,
102+ "sonar.links.issue" ,
103+ "sonar.links.scm" ,
104+ "sonar.links.scm_dev" ,
105+ "sonar.plugins.risk.consent" ,
106+ )
107+
108+ _UNNEEDED_TASK_DATA = (
109+ "analysisId" ,
110+ "componentId" ,
111+ "hasScannerContext" ,
112+ "id" ,
113+ "warningCount" ,
114+ "componentQualifier" ,
115+ "nodeName" ,
116+ "componentName" ,
117+ "componentKey" ,
118+ "submittedAt" ,
119+ "executedAt" ,
120+ "type" ,
121+ )
122+
83123
84124class Project (components .Component ):
85125 """
@@ -954,9 +994,9 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
954994 :rtype: dict
955995 """
956996 log .info ("Exporting %s" , str (self ))
997+ json_data = self ._json .copy ()
998+ json_data .update ({"key" : self .key , "name" : self .name })
957999 try :
958- json_data = self ._json .copy ()
959- json_data .update ({"key" : self .key , "name" : self .name })
9601000 json_data ["binding" ] = self .__export_get_binding ()
9611001 nc = self .new_code ()
9621002 if nc != "" :
@@ -983,10 +1023,16 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
9831023 last_task = self .last_task ()
9841024 json_data ["backgroundTasks" ] = {}
9851025 if last_task :
1026+ ctxt = last_task .scanner_context ()
1027+ if ctxt :
1028+ ctxt = {k : v for k , v in ctxt .items () if k not in _UNNEEDED_CONTEXT_DATA }
1029+ t_hist = []
1030+ for t in self .task_history ():
1031+ t_hist .append ({k : v for k , v in t ._json .items () if k not in _UNNEEDED_TASK_DATA })
9861032 json_data ["backgroundTasks" ] = {
987- "lastTaskScannerContext" : last_task . scanner_context () ,
988- "lastTaskWarnings" : last_task .warnings (),
989- "taskHistory" : [ t . _json for t in self . task_history ()] ,
1033+ "lastTaskScannerContext" : ctxt ,
1034+ # "lastTaskWarnings": last_task.warnings(),
1035+ "taskHistory" : t_hist ,
9901036 }
9911037
9921038 settings_dict = settings .get_bulk (endpoint = self .endpoint , component = self , settings_list = settings_list , include_not_set = False )
@@ -997,14 +1043,17 @@ def export(self, export_settings: types.ConfigSettings, settings_list: dict[str,
9971043 json_data .update (s .to_json ())
9981044 except HTTPError as e :
9991045 if e .response .status_code == HTTPStatus .FORBIDDEN :
1000- log .critical ("Insufficient privileges to access %s, export of this project skipped " , str (self ))
1001- json_data = { "error" : "Insufficient permissions while extracting project" }
1046+ log .critical ("Insufficient privileges to access %s, export of this project interrupted " , str (self ))
1047+ json_data [ "error" ] = "Insufficient permissions while exporting project, export interrupted"
10021048 else :
1003- log .critical ("HTTP error %s while exporting %s, export of this project skipped " , str (e ), str (self ))
1004- json_data = { "error" : f"HTTP error { str (e )} while extracting project" }
1049+ log .critical ("HTTP error %s while exporting %s, export of this project interrupted " , str (e ), str (self ))
1050+ json_data [ "error" ] = f"HTTP error { str (e )} while extracting project"
10051051 except ConnectionError as e :
1006- log .critical ("Connecting error %s while extracting %s, extract of this project skipped" , str (self ), str (e ))
1007- json_data = {"error" : f"Connection error { str (e )} while extracting prooject" }
1052+ log .critical ("Connecting error %s while exporting %s, export of this project interrupted" , str (self ), str (e ))
1053+ json_data ["error" ] = f"Connection error { str (e )} while extracting project, export interrupted"
1054+ except Exception as e :
1055+ log .critical ("Connecting error %s while exporting %s, export of this project interrupted" , str (self ), str (e ))
1056+ json_data ["error" ] = f"Exception { str (e )} while exporting project, export interrupted"
10081057 log .info ("Exporting %s done" , str (self ))
10091058 return util .remove_nones (json_data )
10101059
0 commit comments