@@ -90,7 +90,7 @@ private static void checkQDIntegrationAndDumpMetaData(BrowserStackCredentials br
9090
9191 private static boolean initialQDSetupRequired (BrowserStackCredentials browserStackCredentials ) throws JsonProcessingException {
9292 try {
93- Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .IS_INIT_SETUP_REQUIRED , browserStackCredentials );
93+ Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .getIsInitSetupRequiredEndpoint () , browserStackCredentials );
9494 if (response != null && response .code () == HttpURLConnection .HTTP_OK ) {
9595 ResponseBody responseBody = response .body ();
9696 if (responseBody != null && responseBody .string ().equals ("REQUIRED" )) {
@@ -105,19 +105,54 @@ private static boolean initialQDSetupRequired(BrowserStackCredentials browserSta
105105 return false ;
106106 }
107107
108- private static List <String > getAllPipelines (BrowserStackCredentials browserStackCredentials ) throws JsonProcessingException {
108+ private static List <String > getAllPipelines (BrowserStackCredentials browserStackCredentials ) {
109109 List <String > allPipelines = new ArrayList <>();
110110 Jenkins jenkins = Jenkins .getInstanceOrNull ();
111+ Integer totalPipelines = 0 ;
112+
111113 if (jenkins != null ) {
114+ totalPipelines = jenkins .getAllItems ().size ();
112115 jenkins .getAllItems ().forEach (job -> {
113- if (job instanceof WorkflowJob ) {
114- String pipelineName = job .getFullName ();
116+ try {
117+ // Logging job details
118+ apiUtil .logToQD (
119+ browserStackCredentials ,
120+ String .format (
121+ "Job name: %s, instance type: %s, and is_workflow_job: %s" ,
122+ job .getName (),
123+ job .getClass ().getSimpleName (),
124+ (job instanceof WorkflowJob ) ? "yes" : "no"
125+ )
126+ );
127+ } catch (JsonProcessingException e ) {
128+ // Handling the exception and logging an error
129+ System .err .println ("Error processing JSON for job: " + job .getName ());
130+ e .printStackTrace ();
131+ }
132+
133+ if (job instanceof WorkflowJob ) {
134+ String pipelineName = job .getFullName (); // Getting pipeline name
115135 allPipelines .add (pipelineName );
116136 }
117137 });
118138 } else {
119- apiUtil .logToQD (browserStackCredentials ,"Issue getting Jenkins Instance" );
139+ try {
140+ apiUtil .logToQD (browserStackCredentials , "Issue getting Jenkins Instance" );
141+ } catch (JsonProcessingException e ) {
142+ System .err .println ("Error logging issue with Jenkins instance." );
143+ e .printStackTrace ();
144+ }
145+ }
146+
147+ try {
148+ apiUtil .logToQD (browserStackCredentials ,"Total Pipelines on the jenkins side : " + totalPipelines );
149+ apiUtil .logToQD (browserStackCredentials ,"Total Pipelines detected : " + allPipelines .size ());
150+ } catch (JsonProcessingException e ) {
151+ // Handling the exception and logging an error
152+ System .err .println ("Error processing JSON for total pipelines: " );
153+ e .printStackTrace ();
120154 }
155+ // Returning the list of filtered pipelines
121156 return allPipelines ;
122157 }
123158
@@ -134,7 +169,8 @@ private static boolean sendPipelinesPaginated(BrowserStackCredentials browserSta
134169 PipelinesPaginated pipelinesPaginated = new PipelinesPaginated (page , totalPages , singlePagePipelineList );
135170 String jsonBody = objectMapper .writeValueAsString (pipelinesPaginated );
136171 RequestBody requestBody = RequestBody .create (MediaType .parse ("application/json" ), jsonBody );
137- Response response = apiUtil .makePostRequestToQd (Constants .QualityDashboardAPI .SAVE_PIPELINES , browserStackCredentials , requestBody );
172+ Response response = apiUtil .makePostRequestToQd (Constants .QualityDashboardAPI .getSavePipelinesEndpoint (), browserStackCredentials , requestBody );
173+ apiUtil .logToQD (browserStackCredentials , "Sending page " + page + " with " + singlePagePipelineList .size () + " pipelines" );
138174 if (response == null || response .code () != HttpURLConnection .HTTP_OK ) {
139175 apiUtil .logToQD (browserStackCredentials ,"Got Non 200 response while saving projects" );
140176 isSuccess = false ;
@@ -188,7 +224,7 @@ private static void sendBuildsPaginated(BrowserStackCredentials browserStackCred
188224 BuildResultsPaginated buildResultsPaginated = new BuildResultsPaginated (page , totalPages , buildResultList );
189225 String jsonBody = objectMapper .writeValueAsString (buildResultsPaginated );
190226 RequestBody requestBody = RequestBody .create (MediaType .parse ("application/json" ), jsonBody );
191- Response response = apiUtil .makePostRequestToQd (Constants .QualityDashboardAPI .SAVE_PIPELINE_RESULTS , browserStackCredentials , requestBody );
227+ Response response = apiUtil .makePostRequestToQd (Constants .QualityDashboardAPI .getSavePipelineResultsEndpoint () , browserStackCredentials , requestBody );
192228 if (response == null || response .code () != HttpURLConnection .HTTP_OK ) {
193229 apiUtil .logToQD (browserStackCredentials ,"Got Non 200 response while saving projects" );
194230 break ;
@@ -202,7 +238,7 @@ private static void sendBuildsPaginated(BrowserStackCredentials browserStackCred
202238 private static int getHistoryForDays (BrowserStackCredentials browserStackCredentials ) {
203239 int no_of_days = 90 ;
204240 try {
205- Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .HISTORY_FOR_DAYS , browserStackCredentials );
241+ Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .getHistoryForDaysEndpoint () , browserStackCredentials );
206242 if (response != null && response .code () == HttpURLConnection .HTTP_OK ) {
207243 ResponseBody responseBody = response .body ();
208244 if (responseBody != null ) {
@@ -221,7 +257,7 @@ private static int getHistoryForDays(BrowserStackCredentials browserStackCredent
221257 private static int getProjectPageSize (BrowserStackCredentials browserStackCredentials ) {
222258 int projectPageSize = 2000 ;
223259 try {
224- Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .PROJECTS_PAGE_SIZE , browserStackCredentials );
260+ Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .getProjectsPageSizeEndpoint () , browserStackCredentials );
225261 if (response != null && response .code () == HttpURLConnection .HTTP_OK ) {
226262 ResponseBody responseBody = response .body ();
227263 if (responseBody != null ) {
@@ -240,7 +276,7 @@ private static int getProjectPageSize(BrowserStackCredentials browserStackCreden
240276 private static int getResultPageSize (BrowserStackCredentials browserStackCredentials ) {
241277 int resultPageSize = 1000 ;
242278 try {
243- Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .RESULTS_PAGE_SIZE , browserStackCredentials );
279+ Response response = apiUtil .makeGetRequestToQd (Constants .QualityDashboardAPI .getResultsPageSizeEndpoint () , browserStackCredentials );
244280 if (response != null && response .code () == HttpURLConnection .HTTP_OK ) {
245281 ResponseBody responseBody = response .body ();
246282 if (responseBody != null ) {
0 commit comments