@@ -105,19 +105,54 @@ private static boolean initialQDSetupRequired(BrowserStackCredentials browserSta
105
105
return false ;
106
106
}
107
107
108
- private static List <String > getAllPipelines (BrowserStackCredentials browserStackCredentials ) throws JsonProcessingException {
108
+ private static List <String > getAllPipelines (BrowserStackCredentials browserStackCredentials ) {
109
109
List <String > allPipelines = new ArrayList <>();
110
110
Jenkins jenkins = Jenkins .getInstanceOrNull ();
111
+ Integer totalPipelines = 0 ;
112
+
111
113
if (jenkins != null ) {
114
+ totalPipelines = jenkins .getAllItems ().size ();
112
115
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
115
135
allPipelines .add (pipelineName );
116
136
}
117
137
});
118
138
} 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 ();
120
154
}
155
+ // Returning the list of filtered pipelines
121
156
return allPipelines ;
122
157
}
123
158
@@ -135,6 +170,7 @@ private static boolean sendPipelinesPaginated(BrowserStackCredentials browserSta
135
170
String jsonBody = objectMapper .writeValueAsString (pipelinesPaginated );
136
171
RequestBody requestBody = RequestBody .create (MediaType .parse ("application/json" ), jsonBody );
137
172
Response response = apiUtil .makePostRequestToQd (Constants .QualityDashboardAPI .getSavePipelinesEndpoint (), browserStackCredentials , requestBody );
173
+ apiUtil .logToQD (browserStackCredentials , "Sending page " + page + " with " + singlePagePipelineList .size () + " pipelines" );
138
174
if (response == null || response .code () != HttpURLConnection .HTTP_OK ) {
139
175
apiUtil .logToQD (browserStackCredentials ,"Got Non 200 response while saving projects" );
140
176
isSuccess = false ;
0 commit comments