@@ -538,12 +538,13 @@ private Map<CLEANUP_LEFTOVER_COMPONENTS, Integer> cleanupWholeProjects(OpenProje
538538
539539 CLEANUP_LEFTOVER_COMPONENTS objectType = CLEANUP_LEFTOVER_COMPONENTS .PLTF_PROJECT ;
540540 // Note: the secret passed here is the corresponding to the ODS CD webhook proxy
541- return runDeleteAdminJob (
541+ return runDeleteAdminJobAndSetAsLastExecutionJobToProject (
542542 deleteProjectAdminJob ,
543543 project .getProjectKey (),
544544 openshiftJenkinsTriggerSecret ,
545545 componentId ,
546- objectType );
546+ objectType ,
547+ project );
547548 }
548549
549550 logger .debug ("Project {} not affected from cleanup" , project .getProjectKey ());
@@ -558,13 +559,14 @@ private Map<CLEANUP_LEFTOVER_COMPONENTS, Integer> cleanupQuickstartersOnly(
558559 .map (q1 -> q1 .get (OpenProjectData .COMPONENT_ID_KEY ))
559560 .map (
560561 component ->
561- runDeleteAdminJob (
562+ runDeleteAdminJobAndSetAsLastExecutionJobToProject (
562563 jenkinsPipelineProperties .getDeleteComponentsQuickstarter (),
563564 project .getProjectKey (),
564565 project .getWebhookProxySecret (), // Note: the secret passed here is the
565566 // corresponding to the project CD webhook proxy
566567 component ,
567- CLEANUP_LEFTOVER_COMPONENTS .QUICKSTARTER ))
568+ CLEANUP_LEFTOVER_COMPONENTS .QUICKSTARTER ,
569+ project ))
568570 .filter (m -> !m .isEmpty ())
569571 .mapToInt (e -> 1 )
570572 .sum ();
@@ -578,12 +580,14 @@ private Map<CLEANUP_LEFTOVER_COMPONENTS, Integer> cleanupQuickstartersOnly(
578580 }
579581 }
580582
581- private Map <CLEANUP_LEFTOVER_COMPONENTS , Integer > runDeleteAdminJob (
582- Quickstarter adminQuickstarter ,
583- String projectKey ,
584- String webhookProxySecret ,
585- String componentId ,
586- CLEANUP_LEFTOVER_COMPONENTS objectType ) {
583+ private Map <CLEANUP_LEFTOVER_COMPONENTS , Integer >
584+ runDeleteAdminJobAndSetAsLastExecutionJobToProject (
585+ Quickstarter adminQuickstarter ,
586+ String projectKey ,
587+ String webhookProxySecret ,
588+ String componentId ,
589+ CLEANUP_LEFTOVER_COMPONENTS objectType ,
590+ OpenProjectData project ) {
587591 String projectId = projectKey .toLowerCase ();
588592 Map <String , String > options = buildAdminJobOptions (projectId , componentId );
589593 Job job = new Job (adminQuickstarter , odsGitRef );
@@ -592,14 +596,26 @@ private Map<CLEANUP_LEFTOVER_COMPONENTS, Integer> runDeleteAdminJob(
592596 logger .debug ("Calling job {} for project {}" , job .getId (), projectKey );
593597 ExecutionsData data = prepareAndExecuteJob (job , options , webhookProxySecret );
594598 logger .info ("Result of cleanup: {}" , data .toString ());
599+
600+ if (project .getLastExecutionJobs () == null ) {
601+ project .setLastExecutionJobs (new ArrayList <ExecutionJob >());
602+ }
603+
604+ ExecutionJob result = new ExecutionJob ();
605+ result .setName (data .getJobName ());
606+ result .setUrl (data .getPermalink ());
607+
608+ project .getLastExecutionJobs ().add (result );
609+
595610 return Collections .emptyMap ();
596611 } catch (RuntimeException | IOException e ) {
597612 logger .debug (
598613 "Could not start job {} for project {}/component {} : {}" ,
599614 job .getId (),
600615 projectKey ,
601616 componentId ,
602- e .getMessage ());
617+ e .getMessage (),
618+ e );
603619 Map <CLEANUP_LEFTOVER_COMPONENTS , Integer > leftovers = new HashMap <>();
604620
605621 leftovers .put (objectType , 1 );
0 commit comments