diff --git a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap index e2150863d8873c29bbac9c78a0ef71a81b7c9e1f..be55515daa4d9ff1b555001a4cab43782c826655 100644 --- a/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/gitlab.spec.ts.snap @@ -190,6 +190,49 @@ Object { } `; +exports[`workers/pr/changelog/gitlab getChangeLogJSON supports self-hosted gitlab changelog 1`] = ` +Object { + "hasReleaseNotes": false, + "project": Object { + "apiBaseUrl": "https://git.test.com/api/v4/", + "baseUrl": "https://git.test.com/", + "depName": "renovate", + "gitlab": "meno/dropzone", + "repository": "https://git.test.com/meno/dropzone/", + }, + "versions": Array [ + Object { + "changes": Array [], + "compare": Object {}, + "date": undefined, + "releaseNotes": null, + "version": "5.6.1", + }, + Object { + "changes": Array [], + "compare": Object {}, + "date": "2020-02-13T15:37:00.000Z", + "releaseNotes": null, + "version": "5.6.0", + }, + Object { + "changes": Array [], + "compare": Object {}, + "date": undefined, + "releaseNotes": null, + "version": "5.5.0", + }, + Object { + "changes": Array [], + "compare": Object {}, + "date": "2018-08-24T14:23:00.000Z", + "releaseNotes": null, + "version": "5.4.0", + }, + ], +} +`; + exports[`workers/pr/changelog/gitlab getChangeLogJSON uses GitLab tags 1`] = ` Object { "hasReleaseNotes": true, diff --git a/lib/workers/pr/changelog/gitlab.spec.ts b/lib/workers/pr/changelog/gitlab.spec.ts index ea83bb69133a1530b8ac07860607018b929f50e6..1ba89095e1fa7e697c578f70bc607c6fcde560b4 100644 --- a/lib/workers/pr/changelog/gitlab.spec.ts +++ b/lib/workers/pr/changelog/gitlab.spec.ts @@ -189,5 +189,22 @@ describe(getName(__filename), () => { }) ).toMatchSnapshot(); }); + it('supports self-hosted gitlab changelog', async () => { + httpMock.scope('https://git.test.com').persist().get(/.*/).reply(200, []); + hostRules.add({ + hostType: PLATFORM_TYPE_GITLAB, + baseUrl: 'https://git.test.com/', + token: 'abc', + }); + process.env.GITHUB_ENDPOINT = ''; + expect( + await getChangeLogJSON({ + ...upgrade, + platform: PLATFORM_TYPE_GITLAB, + sourceUrl: 'https://git.test.com/meno/dropzone/', + endpoint: 'https://git.test.com/api/v4/', + }) + ).toMatchSnapshot(); + }); }); }); diff --git a/lib/workers/pr/changelog/index.ts b/lib/workers/pr/changelog/index.ts index c6b45557c29f24f0e0280481acd65c9396050b14..efb383a005a62bd83c49bc67c0bc3c734c9951c6 100644 --- a/lib/workers/pr/changelog/index.ts +++ b/lib/workers/pr/changelog/index.ts @@ -27,7 +27,11 @@ export async function getChangeLogJSON( let res: ChangeLogResult | null = null; - if (args.sourceUrl?.includes('gitlab')) { + if ( + args.sourceUrl?.includes('gitlab') || + (args.platform === 'gitlab' && + new URL(args.sourceUrl).hostname === new URL(args.endpoint).hostname) + ) { res = await sourceGitlab.getChangeLogJSON({ ...args, releases }); } else { res = await sourceGithub.getChangeLogJSON({ ...args, releases });