@@ -192,28 +192,40 @@ class PipelineStatusProcessor : AgentObserver, GitPushListener {
192
192
private fun handleWorkflowFailure (workflowRun : GHWorkflowRun , commitSha : String ) {
193
193
try {
194
194
log.info(" Analyzing workflow failure for commit: $commitSha " )
195
-
195
+
196
196
// 获取失败的构建详情
197
197
val failureDetails = getWorkflowFailureDetails(workflowRun)
198
-
198
+
199
199
// 构建详细的错误通知
200
200
val detailedMessage = buildDetailedFailureMessage(workflowRun, commitSha, failureDetails)
201
-
201
+
202
202
AutoDevNotifications .notify(
203
203
project!! ,
204
204
detailedMessage,
205
205
NotificationType .ERROR
206
206
)
207
-
207
+
208
208
// 记录详细日志
209
209
log.info(" Workflow failure details for commit $commitSha : $failureDetails " )
210
-
210
+
211
211
} catch (e: Exception ) {
212
212
log.error(" Error analyzing workflow failure for commit: $commitSha " , e)
213
- // 回退到简单通知
213
+
214
+ // 提供更好的错误回退消息
215
+ val fallbackMessage = if (e.message?.contains(" admin rights" , ignoreCase = true ) == true ||
216
+ e.message?.contains(" 403" , ignoreCase = true ) == true ) {
217
+ " ❌ GitHub Action failed for commit: ${commitSha.take(7 )} - ${workflowRun.conclusion} \n " +
218
+ " ⚠️ Detailed logs unavailable - admin rights required\n " +
219
+ " View details at: ${workflowRun.htmlUrl} "
220
+ } else {
221
+ " ❌ GitHub Action failed for commit: ${commitSha.take(7 )} - ${workflowRun.conclusion} \n " +
222
+ " URL: ${workflowRun.htmlUrl} \n " +
223
+ " Error getting details: ${e.message} "
224
+ }
225
+
214
226
AutoDevNotifications .notify(
215
227
project!! ,
216
- " ❌ GitHub Action failed for commit: ${commitSha.take( 7 )} - ${workflowRun.conclusion} \n URL: ${workflowRun.htmlUrl} " ,
228
+ fallbackMessage ,
217
229
NotificationType .ERROR
218
230
)
219
231
}
@@ -278,7 +290,18 @@ class PipelineStatusProcessor : AgentObserver, GitPushListener {
278
290
}
279
291
}
280
292
} catch (e: Exception ) {
281
- log.error(" Error downloading job logs for job: ${job.name} " , e)
293
+ log.warn(" Cannot download job logs for job: ${job.name} - ${e.message} " )
294
+
295
+ // Check if it's a permission error
296
+ if (e.message?.contains(" admin rights" , ignoreCase = true ) == true ||
297
+ e.message?.contains(" 403" , ignoreCase = true ) == true ) {
298
+ log.info(" Admin rights required to download job logs. Falling back to alternative approach." )
299
+ return " ⚠️ Job logs unavailable - admin rights required to download logs from GitHub Actions.\n " +
300
+ " Job URL: ${job.htmlUrl} \n " +
301
+ " You can view the logs directly at: ${job.htmlUrl} "
302
+ }
303
+
304
+ // Try alternative API approach for other errors
282
305
getLogsViaDirectAPI(workflowRun, job.id)
283
306
}
284
307
}
@@ -305,7 +328,17 @@ class PipelineStatusProcessor : AgentObserver, GitPushListener {
305
328
}
306
329
}
307
330
} catch (e: Exception ) {
308
- log.error(" Error downloading workflow logs" , e)
331
+ log.warn(" Cannot download workflow logs - ${e.message} " )
332
+
333
+ // Check if it's a permission error
334
+ if (e.message?.contains(" admin rights" , ignoreCase = true ) == true ||
335
+ e.message?.contains(" 403" , ignoreCase = true ) == true ) {
336
+ log.info(" Admin rights required to download workflow logs." )
337
+ return " ⚠️ Workflow logs unavailable - admin rights required to download logs from GitHub Actions.\n " +
338
+ " Workflow URL: ${workflowRun.htmlUrl} \n " +
339
+ " You can view the logs directly at: ${workflowRun.htmlUrl} "
340
+ }
341
+
309
342
null
310
343
}
311
344
}
0 commit comments