Skip to content

Commit

Permalink
Merge pull request #21929 from elaine-mattos/feature/gitlab-issues
Browse files Browse the repository at this point in the history
scaffolder-backend-module-gitlab: add gitlab:issues:create custom action
  • Loading branch information
benjdlambert committed Jan 10, 2024
2 parents 0fde4cb + 5e554f1 commit add0352
Show file tree
Hide file tree
Showing 12 changed files with 1,158 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-terms-provide.md
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-gitlab': patch
---

Add Scaffolder custom action that creates GitLab issues called `gitlab:issues:create`
20 changes: 20 additions & 0 deletions plugins/scaffolder-backend-module-gitlab/README.md
Expand Up @@ -24,6 +24,7 @@ import {
createGitlabProjectDeployTokenAction,
createGitlabProjectVariableAction,
createGitlabGroupEnsureExistsAction,
createGitlabIssueAction,
} from '@backstage/plugin-scaffolder-backend-module-gitlab';

// Create BuiltIn Actions
Expand All @@ -41,6 +42,7 @@ const actions = [
createGitlabProjectDeployTokenAction({ integrations: integrations }),
createGitlabProjectVariableAction({ integrations: integrations }),
createGitlabGroupEnsureExistsAction({ integrations: integrations }),
createGitlabIssueAction({ integrations: integrations }),
];

// Create Scaffolder Router
Expand Down Expand Up @@ -160,8 +162,26 @@ spec:
repoContentsUrl: ${{ steps['publish'].output.repoContentsUrl }}
catalogInfoPath: '/catalog-info.yaml'

- id: gitlabIssue
name: Issues
action: gitlab:issues:create
input:
repoUrl: ${{ parameters.repoUrl }}
token: ${{ secrets.USER_OAUTH_TOKEN }}
projectId: 1111111
title: Test Issue
assignees:
- 2222222
description: This is the description of the issue
confidential: true
createdAt: 2022-09-27 18:00:00.000
dueDate: 2024-09-28 12:00:00.000
epicId: 3333333
labels: phase1:label1,phase2:label2
output:
links:
- title: Repository
url: ${{ steps['publish'].output.remoteUrl }}
- title: Link to new issue
url: ${{ steps['gitlabIssue'].output.issueUrl }}
```
38 changes: 38 additions & 0 deletions plugins/scaffolder-backend-module-gitlab/api-report.md
Expand Up @@ -22,6 +22,34 @@ export const createGitlabGroupEnsureExistsAction: (options: {
}
>;

// @public
export const createGitlabIssueAction: (options: {
integrations: ScmIntegrationRegistry;
}) => TemplateAction<
{
title: string;
repoUrl: string;
projectId: number;
token?: string | undefined;
assignees?: number[] | undefined;
confidential?: boolean | undefined;
description?: string | undefined;
createdAt?: string | undefined;
dueDate?: string | undefined;
discussionToResolve?: string | undefined;
epicId?: number | undefined;
labels?: string | undefined;
issueType?: IssueType | undefined;
mergeRequestToResolveDiscussionsOf?: number | undefined;
milestoneId?: number | undefined;
weight?: number | undefined;
},
{
issueUrl: string;
issueId: number;
}
>;

// @public
export const createGitlabProjectAccessTokenAction: (options: {
integrations: ScmIntegrationRegistry;
Expand Down Expand Up @@ -146,4 +174,14 @@ export const createPublishGitlabMergeRequestAction: (options: {
},
JsonObject
>;

// @public
export enum IssueType {
// (undocumented)
INCIDENT = 'incident',
// (undocumented)
ISSUE = 'issue',
// (undocumented)
TEST = 'test_case',
}
```
4 changes: 3 additions & 1 deletion plugins/scaffolder-backend-module-gitlab/package.json
Expand Up @@ -38,13 +38,15 @@
"@backstage/plugin-scaffolder-node": "workspace:^",
"@gitbeaker/core": "^35.8.0",
"@gitbeaker/node": "^35.8.0",
"@gitbeaker/rest": "^39.25.0",
"yaml": "^2.0.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@backstage/core-app-api": "workspace:^"
"@backstage/core-app-api": "workspace:^",
"jest-date-mock": "^1.0.8"
},
"files": [
"dist"
Expand Down
@@ -0,0 +1,85 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TemplateExample } from '@backstage/plugin-scaffolder-node';
import yaml from 'yaml';
import { commonGitlabConfigExample } from '../commonGitlabConfig';

export const examples: TemplateExample[] = [
{
description: 'Create a GitLab issue with minimal options',
example: yaml.stringify({
steps: [
{
id: 'gitlabIssue',
name: 'Issues',
action: 'gitlab:issues:create',
input: {
...commonGitlabConfigExample,
projectId: 12,
title: 'Test Issue',
description: 'This is the description of the issue',
},
},
],
}),
},
{
description: 'Create a GitLab issue with assignees and date options',
example: yaml.stringify({
steps: [
{
id: 'gitlabIssue',
name: 'Issues',
action: 'gitlab:issues:create',
input: {
...commonGitlabConfigExample,
projectId: 12,
title: 'Test Issue',
assignees: [18],
description: 'This is the description of the issue',
createdAt: '2022-09-27 18:00:00.000',
dueDate: '2022-09-28 12:00:00.000',
},
},
],
}),
},
{
description: 'Create a GitLab Issue with several options',
example: yaml.stringify({
steps: [
{
id: 'gitlabIssue',
name: 'Issues',
action: 'gitlab:issues:create',
input: {
...commonGitlabConfigExample,
projectId: 12,
title: 'Test Issue',
assignees: [18, 15],
description: 'This is the description of the issue',
confidential: false,
createdAt: '2022-09-27 18:00:00.000',
dueDate: '2022-09-28 12:00:00.000',
discussionToResolve: 1,
epicId: 1,
labels: 'phase1:label1,phase2:label2',
},
},
],
}),
},
];

0 comments on commit add0352

Please sign in to comment.