@@ -4,6 +4,7 @@ import * as interfaces from 'azure-devops-node-api/interfaces/common/VSSInterfac
44import * as tl from 'azure-pipelines-task-lib/task' ;
55import { IRequestOptions } from 'azure-devops-node-api/interfaces/common/VsoBaseInterfaces' ;
66import * as provenance from "./provenance" ;
7+ import { RequestOptions } from './universal/RequestUtilities' ;
78
89tl . setResourcePath ( path . join ( __dirname , 'module.json' ) , true ) ;
910
@@ -29,13 +30,17 @@ export interface PackagingLocation {
2930}
3031
3132// Getting service urls from resource areas api
32- export async function getServiceUriFromAreaId ( serviceUri : string , accessToken : string , areaId : string ) : Promise < string > {
33+ export async function getServiceUriFromAreaId (
34+ serviceUri : string ,
35+ accessToken : string ,
36+ areaId : string ,
37+ webApiOptions ?: RequestOptions ) : Promise < string > {
3338 const serverType = tl . getVariable ( 'System.ServerType' ) ;
3439 if ( ! serverType || serverType . toLowerCase ( ) !== 'hosted' ) {
3540 return serviceUri ;
3641 }
3742
38- const webApi = getWebApiWithProxy ( serviceUri , accessToken ) ;
43+ const webApi = getWebApiWithProxy ( serviceUri , accessToken , webApiOptions ) ;
3944 const locationApi = await webApi . getLocationsApi ( ) ;
4045
4146 tl . debug ( `Getting URI for area ID ${ areaId } from ${ serviceUri } ` ) ;
@@ -70,7 +75,7 @@ export async function getBlobstoreUriFromBaseServiceUri(serviceUri: string, acce
7075 * The second URI, if existent, will be Packaging's default access point
7176 * The remaining URI's will be alternate Packaging's access points
7277 */
73- export async function getPackagingUris ( protocolType : ProtocolType ) : Promise < PackagingLocation > {
78+ export async function getPackagingUris ( protocolType : ProtocolType , webApiOptions ?: RequestOptions ) : Promise < PackagingLocation > {
7479 tl . debug ( 'Getting Packaging service access points' ) ;
7580 const collectionUrl = tl . getVariable ( 'System.TeamFoundationCollectionUri' ) ;
7681
@@ -90,7 +95,7 @@ export async function getPackagingUris(protocolType: ProtocolType): Promise<Pack
9095 const serviceUri = await getServiceUriFromAreaId ( collectionUrl , accessToken , areaId ) ;
9196 tl . debug ( `Found serviceUri: ${ serviceUri } ` ) ;
9297
93- const webApi = getWebApiWithProxy ( serviceUri ) ;
98+ const webApi = getWebApiWithProxy ( serviceUri , accessToken , webApiOptions ) ;
9499 const locationApi = await webApi . getLocationsApi ( ) ;
95100
96101 tl . debug ( 'Acquiring Packaging endpoints...' ) ;
@@ -140,7 +145,7 @@ function getAreaIdForProtocol(protocolType: ProtocolType): string {
140145 }
141146}
142147
143- export function getWebApiWithProxy ( serviceUri : string , accessToken ?: string ) : vsts . WebApi {
148+ export function getWebApiWithProxy ( serviceUri : string , accessToken ?: string , webApiOptions ?: RequestOptions ) : vsts . WebApi {
144149 if ( ! accessToken ) {
145150 accessToken = getSystemAccessToken ( ) ;
146151 }
@@ -149,7 +154,9 @@ export function getWebApiWithProxy(serviceUri: string, accessToken?: string): vs
149154 const options : IRequestOptions = {
150155 proxy : tl . getHttpProxyConfiguration ( serviceUri ) ,
151156 allowRetries : true ,
152- maxRetries : 5
157+ maxRetries : 5 ,
158+ socketTimeout : webApiOptions && webApiOptions . socketTimeout ,
159+ globalAgentOptions : webApiOptions && webApiOptions . globalAgentOptions
153160 } ;
154161 const webApi = new vsts . WebApi ( serviceUri , credentialHandler , options ) ;
155162 tl . debug ( `Created webApi client for ${ serviceUri } ; options: ${ JSON . stringify ( options ) } ` ) ;
@@ -210,7 +217,8 @@ export async function getFeedRegistryUrl(
210217 feedId : string ,
211218 project : string ,
212219 accessToken ?: string ,
213- useSession ?: boolean ) : Promise < string > {
220+ useSession ?: boolean ,
221+ webApiOptions ?: RequestOptions ) : Promise < string > {
214222 let loc : RegistryLocation ;
215223 switch ( registryType ) {
216224 case RegistryType . npm :
@@ -253,7 +261,7 @@ export async function getFeedRegistryUrl(
253261
254262 tl . debug ( "Getting registry url from " + packagingUrl ) ;
255263
256- const vssConnection = getWebApiWithProxy ( packagingUrl , accessToken ) ;
264+ const vssConnection = getWebApiWithProxy ( packagingUrl , accessToken , webApiOptions ) ;
257265
258266 let sessionId = feedId ;
259267 if ( useSession ) {
0 commit comments