diff --git a/.changeset/red-pens-tickle.md b/.changeset/red-pens-tickle.md new file mode 100644 index 0000000000..110f186d25 --- /dev/null +++ b/.changeset/red-pens-tickle.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': minor +--- + +Added ability to override the commit message and author details for the `publish:bitbucketServer` action. diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 21026c203c..05285d9dc0 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -341,6 +341,9 @@ export function createPublishBitbucketServerAction(options: { sourcePath?: string | undefined; enableLFS?: boolean | undefined; token?: string | undefined; + gitCommitMessage?: string | undefined; + gitAuthorName?: string | undefined; + gitAuthorEmail?: string | undefined; }>; // @public diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts index 52f445098b..6b4fa3d781 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.test.ts @@ -375,7 +375,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'master', auth: { token: 'thing' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -429,7 +433,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'master', auth: { username: 'test-user', password: 'test-password' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -481,7 +489,11 @@ describe('publish:bitbucketServer', () => { defaultBranch: 'main', auth: { token: 'thing' }, logger: mockContext.logger, - gitAuthorInfo: {}, + commitMessage: 'initial commit', + gitAuthorInfo: { + email: undefined, + name: undefined, + }, }); }); @@ -555,6 +567,7 @@ describe('publish:bitbucketServer', () => { auth: { token: 'thing' }, logger: mockContext.logger, defaultBranch: 'master', + commitMessage: 'initial commit', gitAuthorInfo: { name: 'Test', email: 'example@example.com' }, }); }); @@ -574,7 +587,7 @@ describe('publish:bitbucketServer', () => { ], }, scaffolder: { - defaultCommitMessage: 'Test commit message', + defaultCommitMessage: 'initial commit', }, }); @@ -626,7 +639,7 @@ describe('publish:bitbucketServer', () => { auth: { token: 'thing' }, logger: mockContext.logger, defaultBranch: 'master', - commitMessage: 'Test commit message', + commitMessage: 'initial commit', gitAuthorInfo: { email: undefined, name: undefined }, }); }); diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts index d0cde4ad31..8c96c14463 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/bitbucketServer.ts @@ -130,6 +130,9 @@ export function createPublishBitbucketServerAction(options: { sourcePath?: string; enableLFS?: boolean; token?: string; + gitCommitMessage?: string; + gitAuthorName?: string; + gitAuthorEmail?: string; }>({ id: 'publish:bitbucketServer', description: @@ -174,6 +177,21 @@ export function createPublishBitbucketServerAction(options: { description: 'The token to use for authorization to BitBucket Server', }, + gitCommitMessage: { + title: 'Git Commit Message', + type: 'string', + description: `Sets the commit message on the repository. The default value is 'initial commit'`, + }, + gitAuthorName: { + title: 'Author Name', + type: 'string', + description: `Sets the author name for the commit. The default value is 'Scaffolder'`, + }, + gitAuthorEmail: { + title: 'Author Email', + type: 'string', + description: `Sets the author email for the commit.`, + }, }, }, output: { @@ -197,6 +215,9 @@ export function createPublishBitbucketServerAction(options: { defaultBranch = 'master', repoVisibility = 'private', enableLFS = false, + gitCommitMessage = 'initial commit', + gitAuthorName, + gitAuthorEmail, } = ctx.input; const { project, repo, host } = parseRepoUrl(repoUrl, integrations); @@ -241,8 +262,12 @@ export function createPublishBitbucketServerAction(options: { }); const gitAuthorInfo = { - name: config.getOptionalString('scaffolder.defaultAuthor.name'), - email: config.getOptionalString('scaffolder.defaultAuthor.email'), + name: gitAuthorName + ? gitAuthorName + : config.getOptionalString('scaffolder.defaultAuthor.name'), + email: gitAuthorEmail + ? gitAuthorEmail + : config.getOptionalString('scaffolder.defaultAuthor.email'), }; const auth = authConfig.token @@ -260,9 +285,9 @@ export function createPublishBitbucketServerAction(options: { auth, defaultBranch, logger: ctx.logger, - commitMessage: config.getOptionalString( - 'scaffolder.defaultCommitMessage', - ), + commitMessage: gitCommitMessage + ? gitCommitMessage + : config.getOptionalString('scaffolder.defaultCommitMessage'), gitAuthorInfo, });