diff --git a/plugins/scaffolder-backend-module-gitlab/README.md b/plugins/scaffolder-backend-module-gitlab/README.md index 128b91092d..9ca74079b2 100644 --- a/plugins/scaffolder-backend-module-gitlab/README.md +++ b/plugins/scaffolder-backend-module-gitlab/README.md @@ -164,8 +164,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 }} ``` diff --git a/plugins/scaffolder-backend-module-gitlab/sample-templates/template.yaml b/plugins/scaffolder-backend-module-gitlab/sample-templates/template.yaml new file mode 100644 index 0000000000..9078c33483 --- /dev/null +++ b/plugins/scaffolder-backend-module-gitlab/sample-templates/template.yaml @@ -0,0 +1,56 @@ +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: gitlab-demo + title: Gitlab DEMO + description: Scaffolder Gitlab Demo +spec: + owner: backstage/techdocs-core + type: service + + parameters: + - title: Fill in some steps + required: + - name + properties: + name: + title: Name + type: string + description: Unique name of the component + ui:autofocus: true + ui:options: + rows: 5 + - title: Choose a location + required: + - repoUrl + properties: + repoUrl: + title: Repository Location + type: string + ui:field: RepoUrlPicker + ui:options: + allowedHosts: + - gitlab.com + + steps: + - id: gitlabIssue + name: Issues + action: gitlab:issues:create + input: + repoUrl: ${{ parameters.repoUrl }} # git.tech.rz.db.de?owner=devex-core&repo=test-repo + token: ${{ secrets.USER_OAUTH_TOKEN }} + projectId: 52723821 + title: Test Issue + assignees: + - 11013327 + 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: 1456 + labels: test-label1,test-label2 + output: + links: + - title: Link to new issue + url: ${{ steps['gitlabIssue'].output.issueUrl }} + diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabIssueAction.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabIssueAction.ts index 50f03e2575..5f463182b3 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabIssueAction.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/createGitlabIssueAction.ts @@ -21,8 +21,7 @@ import { createTemplateAction, } from '@backstage/plugin-scaffolder-node'; import * as yaml from 'yaml'; -import { - commonGitlabConfig, +import commonGitlabConfig, { commonGitlabConfigExample, } from '../commonGitlabConfig'; import { z } from 'zod'; @@ -160,7 +159,7 @@ function getExamples(): TemplateExample[] { action: 'gitlab:issues:create', input: { ...commonGitlabConfigExample, - projectId: '12', + projectId: 12, title: 'Test Issue', description: 'This is the description of the issue', }, @@ -178,9 +177,9 @@ function getExamples(): TemplateExample[] { action: 'gitlab:issues:create', input: { ...commonGitlabConfigExample, - projectId: '12', + projectId: 12, title: 'Test Issue', - assignees: '18', + 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', @@ -196,19 +195,21 @@ function getExamples(): TemplateExample[] { { id: 'gitlabIssue', name: 'Issues', - action: 'dxc:gitlab:issues:create', + action: 'gitlab:issues:create', input: { ...commonGitlabConfigExample, - projectId: '12', + projectId: 12, title: 'Test Issue', - assignees: '18', + 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: 'test-label1,test-label2', + discussionToResolve: 1, + epicId: 1, + labels: 'phase1:label1,phase2:label2', }, }, ],