Skip to content

Commit d6b55f0

Browse files
Merge pull request #8 from Parfuemerie-Douglas/polish
Polish sourcecode and README.md
2 parents 45ccece + 6f8dd15 commit d6b55f0

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ This plugin contains a collection of actions:
88
- `azure:pipeline:run`
99
- `azure:pipeline:permit`
1010

11-
It utilizes Azure DevOps REST APIs to [create](https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.1), [run](https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-6.1), and [authorize](https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/pipeline-permissions/update-pipeline-permisions-for-resource?view=azure-devops-rest-7.1) Azure pipelines.
11+
It utilizes Azure DevOps REST APIs to
12+
[create](https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-6.1),
13+
[run](https://docs.microsoft.com/en-us/rest/api/azure/devops/pipelines/runs/run-pipeline?view=azure-devops-rest-6.1),
14+
and
15+
[authorize](https://docs.microsoft.com/en-us/rest/api/azure/devops/approvalsandchecks/pipeline-permissions/update-pipeline-permisions-for-resource?view=azure-devops-rest-7.1)
16+
Azure pipelines.
1217

1318
## Getting started
1419

15-
Create your Backstage application using the Backstage CLI as described here: <https://backstage.io/docs/getting-started/create-an-app>.
20+
Create your Backstage application using the Backstage CLI as described here:
21+
<https://backstage.io/docs/getting-started/create-an-app>.
1622

17-
> Note: If you are using this plugin in a Backstage monorepo that contains the code for `@backstage/plugin-scaffolder-backend`, you need to modify your internal build processes to transpile files from the `node_modules` folder as well.
23+
> Note: If you are using this plugin in a Backstage monorepo that contains the
24+
> code for `@backstage/plugin-scaffolder-backend`, you need to modify your
25+
> internal build processes to transpile files from the `node_modules` folder as
26+
> well.
1827
1928
You need to configure the actions in your backend:
2029

@@ -25,7 +34,9 @@ You need to configure the actions in your backend:
2534
yarn add --cwd packages/backend @parfuemerie-douglas/scaffolder-backend-module-azure-pipelines
2635
```
2736

28-
Configure the actions (you can check the [docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions) to see all options):
37+
Configure the actions (you can check the
38+
[docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions)
39+
to see all options):
2940

3041
```typescript
3142
// packages/backend/src/plugins/scaffolder.ts
@@ -60,7 +71,13 @@ return await createRouter({
6071
});
6172
```
6273

63-
The Azure pipeline actions use an [Azure PAT (personal access token)](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate) for authorization. The PAT requires `Read & execute` permission for `Build` for the `azure:pipeline:create` and `azure:pipeline:run` actions. For the `azure:pipeline:permit` action the PAT requires `Read, query, & manage` permission for `Service Connections`. Simply add the PAT to your `app-config.yaml`:
74+
The Azure pipeline actions use an [Azure PAT (personal access
75+
token)](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate)
76+
for authorization. The PAT requires `Read & execute` permission for `Build` for
77+
the `azure:pipeline:create` and `azure:pipeline:run` actions. For the
78+
`azure:pipeline:permit` action the PAT requires `Read, query, & manage`
79+
permission for `Service Connections`. Simply add the PAT to your
80+
`app-config.yaml`:
6481

6582
```yaml
6683
# app-config.yaml
@@ -71,11 +88,13 @@ integrations:
7188
token: ${AZURE_TOKEN}
7289
```
7390
74-
Read more on integrations in Backstage in the [Integrations documentation](https://backstage.io/docs/integrations/).
91+
Read more on integrations in Backstage in the [Integrations
92+
documentation](https://backstage.io/docs/integrations/).
7593
7694
## Using the template
7795
78-
After loading and configuring the Azure pipeline template actions, you can use the actions in your template:
96+
After loading and configuring the Azure pipeline template actions, you can use
97+
the actions in your template:
7998
8099
```yaml
81100
# template.yaml
@@ -192,6 +211,12 @@ spec:
192211
entityRef: ${{ steps.register.output.entityRef }}
193212
```
194213
195-
**_Note_**: The `azure:pipeline:permit` action authorizes/unauthorizes a pipeline for a given resource. To authorize a pipeline for a [service endpoint](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-service-endpoints-overview) set `resourceType` to `endpoint`, provide `resourceId` with the service endpoint ID (replace `<serviceEndpointId>` in the example code above), and set authorized to `true`.
214+
**_Note_**: The `azure:pipeline:permit` action authorizes/unauthorizes a
215+
pipeline for a given resource. To authorize a pipeline for a [service
216+
endpoint](https://docs.microsoft.com/en-us/azure/virtual-network/virtual-network-service-endpoints-overview)
217+
set `resourceType` to `endpoint`, provide `resourceId` with the service endpoint
218+
ID (replace `<serviceEndpointId>` in the example code above), and set authorized
219+
to `true`.
196220

197-
You can find a list of all registred actions including their parameters at the `/create/actions` route in your Backstage application.
221+
You can find a list of all registred actions including their parameters at the
222+
`/create/actions` route in your Backstage application.

src/actions/run/permitAzurePipeline.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const permitAzurePipelineAction = (options: {
110110

111111
const token = ctx.input.token ?? integrationConfig.config.token!;
112112

113-
if (ctx.input.authorized == true) {
113+
if (ctx.input.authorized === true) {
114114
ctx.logger.info(
115115
`Authorizing Azure pipeline with ID ${pipelineId} for ${resourceType} with ID ${resourceId}.`
116116
);
@@ -138,12 +138,12 @@ export const permitAzurePipelineAction = (options: {
138138
pipelines: [
139139
{
140140
authorized: authorized,
141-
id: parseInt(pipelineId),
141+
id: parseInt(pipelineId, 10),
142142
},
143143
],
144144
}),
145145
}
146-
).then(function (response) {
146+
).then((response) => {
147147
if (response.ok) {
148148
ctx.logger.info(
149149
`Successfully changed the Azure pipeline permissions.`

src/actions/run/runAzurePipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const runAzurePipelineAction = (options: {
104104
},
105105
}),
106106
}
107-
).then(function (response) {
107+
).then((response) => {
108108
if (response.ok) {
109109
ctx.logger.info(`Successfully ran Azure pipeline.`);
110110
} else {

0 commit comments

Comments
 (0)