@@ -81,7 +81,8 @@ export class Utils {
81
81
// It cannot be linked to the repository, as GitHub serves the image from a CDN,
82
82
// which gets blocked by the browser, resulting in an empty image.
83
83
private static MARKDOWN_HEADER_PNG_URL : string = 'https://media.jfrog.com/wp-content/uploads/2024/09/02161430/jfrog-job-summary.svg' ;
84
- private static isSummaryHeaderAccessible : boolean ;
84
+ // Flag to indicate if the summary header is accessible, can be undefined if not checked yet.
85
+ private static isSummaryHeaderAccessible : boolean | undefined = undefined ;
85
86
86
87
/**
87
88
* Retrieves server credentials for accessing JFrog's server
@@ -913,18 +914,31 @@ export class Utils {
913
914
return `` ;
914
915
}
915
916
917
+ /**
918
+ * Checks if the header image is accessible via the internet.
919
+ * Saves the result in a static variable to avoid multiple checks.
920
+ * @private
921
+ */
916
922
private static async isHeaderPngAccessible ( ) : Promise < boolean > {
923
+ if ( this . isSummaryHeaderAccessible != undefined ) {
924
+ return this . isSummaryHeaderAccessible ;
925
+ }
917
926
const url : string = this . MARKDOWN_HEADER_PNG_URL ;
918
927
const httpClient : HttpClient = new HttpClient ( ) ;
919
928
try {
920
- const response : HttpClientResponse = await httpClient . head ( url ) ;
921
- return response . message . statusCode === 200 ;
929
+ // Set timeout to 5 seconds
930
+ const requestOptions : OutgoingHttpHeaders = {
931
+ socketTimeout : 5000 ,
932
+ } ;
933
+ const response : HttpClientResponse = await httpClient . head ( url , requestOptions ) ;
934
+ this . isSummaryHeaderAccessible = response . message . statusCode === 200 ;
922
935
} catch ( error ) {
923
936
core . warning ( 'No internet access to the header image, using the text header instead.' ) ;
924
- return false ;
937
+ this . isSummaryHeaderAccessible = false ;
925
938
} finally {
926
939
httpClient . dispose ( ) ;
927
940
}
941
+ return this . isSummaryHeaderAccessible ;
928
942
}
929
943
930
944
private static getTempDirectory ( ) : string {
0 commit comments