@@ -74,6 +74,18 @@ export const getBitbucketReposFromConfig = async (config: BitbucketConnectionCon
7474 let allRepos : BitbucketRepository [ ] = [ ] ;
7575 let allWarnings : string [ ] = [ ] ;
7676
77+ if ( config . all === true ) {
78+ if ( client . deploymentType === BITBUCKET_SERVER ) {
79+ const { repos, warnings } = await serverGetAllRepos ( client ) ;
80+ allRepos = allRepos . concat ( repos ) ;
81+ allWarnings = allWarnings . concat ( warnings ) ;
82+ } else {
83+ const warning = `Ignoring option all:true in config: not supported for Bitbucket Cloud` ;
84+ logger . warn ( warning ) ;
85+ allWarnings = allWarnings . concat ( warning ) ;
86+ }
87+ }
88+
7789 if ( config . workspaces ) {
7890 const { repos, warnings } = await client . getReposForWorkspace ( client , config . workspaces ) ;
7991 allRepos = allRepos . concat ( repos ) ;
@@ -553,6 +565,26 @@ async function serverGetRepos(client: BitbucketClient, repoList: string[]): Prom
553565 } ;
554566}
555567
568+ async function serverGetAllRepos ( client : BitbucketClient ) : Promise < { repos : ServerRepository [ ] , warnings : string [ ] } > {
569+ logger . debug ( `Fetching all repos from Bitbucket Server...` ) ;
570+ const path = `/rest/api/1.0/repos` as ServerGetRequestPath ;
571+ const { durationMs, data } = await measure ( async ( ) => {
572+ const fetchFn = ( ) => getPaginatedServer < ServerRepository > ( path , async ( url , start ) => {
573+ const response = await client . apiClient . GET ( url , {
574+ params : { query : { start } }
575+ } ) ;
576+ const { data, error } = response ;
577+ if ( error ) {
578+ throw new Error ( `Failed to fetch all repos: ${ JSON . stringify ( error ) } ` ) ;
579+ }
580+ return data ;
581+ } ) ;
582+ return fetchWithRetry ( fetchFn , `all repos` , logger ) ;
583+ } ) ;
584+ logger . debug ( `Found ${ data . length } total repos in ${ durationMs } ms.` ) ;
585+ return { repos : data , warnings : [ ] } ;
586+ }
587+
556588export function serverShouldExcludeRepo ( repo : BitbucketRepository , config : BitbucketConnectionConfig ) : boolean {
557589 const serverRepo = repo as ServerRepository ;
558590
0 commit comments