# matthias-kainer-scaffolder-backend-module-azure-pipelines

> A collection of Backstage scaffolder backend modules for Azure pipelines.

Latest version **0.4.4-beta.0** (published 2022-10-11) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install matthias-kainer-scaffolder-backend-module-azure-pipelines
pnpm add matthias-kainer-scaffolder-backend-module-azure-pipelines
yarn add matthias-kainer-scaffolder-backend-module-azure-pipelines
bun add matthias-kainer-scaffolder-backend-module-azure-pipelines
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.4-beta.0 |
| Published | 2022-10-11 |
| First published | 2022-10-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 55.8 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Parfümerie Douglas GmbH |
| Maintainers | matkainer |
| Keywords | backstage, azure-devops, azure-pipelines, backstage-plugin, backstage-template |

## Links

- npm: https://www.npmjs.com/package/matthias-kainer-scaffolder-backend-module-azure-pipelines
- Repository: https://github.com/Parfuemerie-Douglas/scaffolder-backend-module-azure-pipelines
- Homepage: https://github.com/Parfuemerie-Douglas/scaffolder-backend-module-azure-pipelines#readme
- Issues: https://github.com/Parfuemerie-Douglas/scaffolder-backend-module-azure-pipelines/issues
- npm.io page: https://npm.io/package/matthias-kainer-scaffolder-backend-module-azure-pipelines

## Dependencies (7)

- [node-fetch](https://npm.io/package/node-fetch.md) 2
- [@backstage/types](https://npm.io/package/@backstage/types.md) ^1.0.0
- [@backstage/errors](https://npm.io/package/@backstage/errors.md) ^1.1.2-next.0
- [@types/node-fetch](https://npm.io/package/@types/node-fetch.md) ^2.6.2
- [@backstage/integration](https://npm.io/package/@backstage/integration.md) ^1.3.2-next.0
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.15.2-next.0
- [@backstage/plugin-scaffolder-backend](https://npm.io/package/@backstage/plugin-scaffolder-backend.md) ^1.7.0-next.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.4.4-beta.0 (latest) — 2022-10-11

## README

# scaffolder-backend-module-azure-pipelines

Welcome to the Microsoft Azure pipeline actions for the `scaffolder-backend`.

This plugin contains a collection of actions:

- `azure:pipeline:create`
- `azure:pipeline:run`
- `azure:pipeline:permit`

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.

## Getting started

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

> 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.

You need to configure the actions in your backend:

## From your Backstage root directory

```sh
# From your Backstage root directory
yarn add --cwd packages/backend @parfuemerie-douglas/scaffolder-backend-module-azure-pipelines
```

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):

```typescript
// packages/backend/src/plugins/scaffolder.ts

import {
  createAzurePipelineAction,
  permitAzurePipelineAction,
  runAzurePipelineAction,
} from "@parfuemerie-douglas/scaffolder-backend-module-azure-pipelines";

const actions = [
  createAzurePipelineAction({ integrations }),
  permitAzurePipelineAction({ integrations }),
  runAzurePipelineAction({ integrations }),
  ...createBuiltInActions({
    containerRunner,
    catalogClient,
    integrations,
    config: env.config,
    reader: env.reader,
  }),
];

return await createRouter({
  containerRunner,
  catalogClient,
  actions,
  logger: env.logger,
  config: env.config,
  database: env.database,
  reader: env.reader,
});
```

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`:

```yaml
# app-config.yaml

integrations:
  azure:
    - host: dev.azure.com
      token: ${AZURE_TOKEN}
```

Read more on integrations in Backstage in the [Integrations
documentation](https://backstage.io/docs/integrations/).

## Using the template

After loading and configuring the Azure pipeline template actions, you can use
the actions in your template:

```yaml
# template.yaml

apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: create-azure-pipeline-demo
  title: Create Azure Pipeline Test
  description: Create Azure pipeline example
spec:
  owner: parfuemerie-douglas
  type: service

  parameters:
    - title: Fill in some steps
      required:
        - name
        - owner
      properties:
        name:
          title: Project name
          type: string
          description: Choose a unique project name.
          ui:field: EntityNamePicker
          ui:autofocus: true
        owner:
          title: Owner
          type: string
          description: Select an owner for the Backstage component.
          ui:field: OwnerPicker
          ui:options:
            allowedKinds:
              - Group
    - title: Choose a location
      description: >-
        Organization is an Azure DevOps organization. Owner is an Azure DevOps project.
        Repository is the name of the repository Backstage will create for you.
      required:
        - repoUrl
      properties:
        repoUrl:
          title: Repository Location
          type: string
          ui:field: RepoUrlPicker
          ui:options:
            allowedHosts:
              - dev.azure.com

  steps:
    - id: fetch
      name: Template Skeleton
      action: fetch:template
      input:
        url: ./skeleton
        values:
          name: ${{ parameters.name }}
          destination: ${{ parameters.repoUrl | parseRepoUrl }}
          owner: ${{ parameters.owner }}

    - id: publish
      name: Publish
      action: publish:azure
      input:
        allowedHosts: ["dev.azure.com"]
        description: This is ${{ parameters.name }}
        repoUrl: ${{ parameters.repoUrl }}

    - id: createAzurePipeline
      name: Create Azure Pipeline
      action: azure:pipeline:create
      input:
        organization: ${{ (parameters.repoUrl | parseRepoUrl)['organization'] }}
        project: ${{ (parameters.repoUrl | parseRepoUrl)['owner'] }}
        folder: "my-azure-pipelines-folder"
        name: ${{ parameters.name }}
        repositoryId: ${{ steps.publish.output.repositoryId }}
        repositoryName: ${{ (parameters.repoUrl | parseRepoUrl)['repo'] }}
        yamlPath: <optional value to your azure pipelines yaml file, defaults to ./azure-pipelines.yaml>

    - id: runAzurePipeline
      name: Run Azure Pipeline
      action: azure:pipeline:run
      input:
        organization: ${{ (parameters.repoUrl | parseRepoUrl)['organization'] }}
        pipelineId: ${{ steps.createAzurePipeline.output.pipelineId }}
        project: ${{ (parameters.repoUrl | parseRepoUrl)['owner'] }}

    - id: permitAzurePipeline
      name: Change Azure Pipeline Permissions
      action: azure:pipeline:permit
      input:
        organization: ${{ (parameters.repoUrl | parseRepoUrl)['organization'] }}
        project: ${{ (parameters.repoUrl | parseRepoUrl)['owner'] }}
        resourceId: <serviceEndpointId>
        resourceType: endpoint
        authorized: true
        pipelineId: ${{ steps.createAzurePipeline.output.pipelineId }}

    - id: register
      name: Register
      action: catalog:register
      input:
        repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
        catalogInfoPath: "/catalog-info.yaml"

  output:
    links:
      - title: Repository
        url: ${{ steps.publish.output.remoteUrl }}
      - title: Pipeline
        url: ${{ steps.createAzurePipeline.output.pipelineUrl }}
      - title: Open in catalog
        icon: catalog
        entityRef: ${{ steps.register.output.entityRef }}
```

**_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`.

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

---
_Source: https://npm.io/package/matthias-kainer-scaffolder-backend-module-azure-pipelines · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
