diff --git a/lib/modules/platform/bitbucket/index.spec.ts b/lib/modules/platform/bitbucket/index.spec.ts index bd5cd4e768b72b..f4f8de3cad9137 100644 --- a/lib/modules/platform/bitbucket/index.spec.ts +++ b/lib/modules/platform/bitbucket/index.spec.ts @@ -277,34 +277,14 @@ describe('modules/platform/bitbucket/index', () => { uuid: '123', full_name: 'some/repo', }) - .get('/2.0/repositories/some/repo/refs/branches/master') - .twice() - .reply(200, { - name: 'branch', - target: { - hash: 'branch_hash', - parents: [{ hash: 'master_hash' }], - }, - }) - .post('/2.0/repositories/some/repo/commit/branch_hash/statuses/build', { + .post('/2.0/repositories/some/repo/commit/HEAD/statuses/build', { name: 'Renovate', state: 'SUCCESSFUL', key: 'Renovate', description: 'Repository Dashboard', url: 'https://developer.mend.io/bitbucket/some/repo', }) - .reply(200) - .get( - '/2.0/repositories/some/repo/commit/branch_hash/statuses?pagelen=100', - ) - .reply(200, { - values: [ - { - key: 'Renovate', - state: 'SUCCESSFUL', - }, - ], - }); + .reply(200); expect( await bitbucket.initRepo({ diff --git a/lib/modules/platform/bitbucket/index.ts b/lib/modules/platform/bitbucket/index.ts index 08817bff3576f4..da2aab1aee8868 100644 --- a/lib/modules/platform/bitbucket/index.ts +++ b/lib/modules/platform/bitbucket/index.ts @@ -226,7 +226,7 @@ export async function initRepo({ if (bbMendAppDashboardStatus) { logger.debug('Creating branch status for Mend App Repository Dashboard'); - await setBranchStatus({ + await setHeadBranchStatus({ branchName: config.defaultBranch, context: 'Renovate', description: 'Repository Dashboard', @@ -527,6 +527,26 @@ export async function setBranchStatus({ await getStatus(branchName, false); } +async function setHeadBranchStatus({ + context, + description, + state, + url, +}: BranchStatusConfig): Promise { + const body = { + name: context, + state: utils.buildStates[state], + key: context, + description, + url, + }; + + await bitbucketHttp.postJson( + `/2.0/repositories/${config.repository}/commit/HEAD/statuses/build`, + { body }, + ); +} + type BbIssue = { id: number; title: string; content?: { raw: string } }; async function findOpenIssues(title: string): Promise {