This is a Backend Plugin containing a set of Custom Actions using the Azure Devops REST API
& azure-devops-node-api.
It contains the following actions:
-
azure:pipeline:run
: run a azure pipeline for a project, with pipeline id
From your Backstage instance root folder:
yarn --cwd packages/backend add @backstage-community/plugin-scaffolder-backend-module-azure-devops
Import the module by modifying the packages/backend/src/index.ts
file on your Backstage instance:
// packages/backend/src/index.ts
backend.add(
import('@backstage-community/plugin-scaffolder-backend-module-azure-devops'),
);
Your Backstage instance must have a valid Azure DevOps integration for for your target host. dev.azure.com
is used by default in the scaffolder actions.
To get started quickly, use the following as an example:
integrations:
azure:
- host: dev.azure.com
credentials:
- personalAccessToken: ${PERSONAL_ACCESS_TOKEN}
You can use the action in any of the steps of your Software Template. See here for an example of a Software Template making use of the Azure Run Action.
spec:
parameters:
- title: Choose a location
required:
- repoUrl
- pipelineId
properties:
repoUrl:
title: Repository Location
type: string
ui:field: RepoUrlPicker
ui:options:
allowedHosts:
- dev.azure.com
pipelineId:
title: Pipeline Id
type: string
description: The Id for the pipeline you want to execute
steps:
- id: runAzurePipeline
name: Run Pipeline
action: azure:pipeline:run
input:
organization: ${{ (parameters.repoUrl | parseRepoUrl)['organization'] }}
pipelineId: ${{ parameters.pipelineId }}
project: ${{ (parameters.repoUrl | parseRepoUrl)['project'] }}
output:
links:
- title: Open in DevOps
icon: catalog
url: ${{ steps['runAzurePipeline'].output.pipelineRunUrl }}
spec:
#[...]
steps:
- id: runAzurePipeline
name: Run Pipeline
action: azure:pipeline:run
input:
#[...]
host: 'AZURE_DEVOPS_HOST'
spec:
parameters:
#[...]
properties:
repoUrl:
ui:field: RepoUrlPicker
ui:options:
#[...]
requestUserCredentials:
secretsKey: USER_OAUTH_TOKEN
additionalScopes:
azure: []
pipelineId:
title: Pipeline Id
type: string
description: The Id for the pipeline you want to execute
steps:
- id: runAzurePipeline
name: Run Pipeline
action: azure:pipeline:run
input:
#[...]
pipelineId: ${{ parameters.pipelineId }}
token: ${{ secrets.USER_OAUTH_TOKEN }}
spec:
parameters:
#[...]
properties:
#[...]
branch:
title: branch
type: string
description: The branch for the pipeline you want to execute
steps:
- id: runAzurePipeline
name: Run Pipeline
action: azure:pipeline:run
input:
#[...]
branch: ${{ parameters.branch }}
spec:
parameters:
#[...]
properties:
#[...]
templateParameters:
type: object
title: Template Parameters
description: Azure DevOps pipeline template parameters in key-value pairs.
steps:
- id: runAzurePipeline
name: Run Pipeline
action: azure:pipeline:run
input:
#[...]
templateParameters:
projectRepo: ${{ (parameters.repoUrl | parseRepoUrl)['repo'] }}
sampleTemplateParameterKey: sampleTemplateParameterValue