@backstage-community/plugin-scaffolder-backend-module-azure-devops
TypeScript icon, indicating that this package has built-in type declarations

0.8.1 • Public • Published

Azure DevOps Actions backend module for the Scaffolder plugin

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

Installation

From your Backstage instance root folder:

yarn --cwd packages/backend add @backstage-community/plugin-scaffolder-backend-module-azure-devops

Configuration

Code

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'),
);

Pre-Requisites

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}

Usage

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.

Example with the azure:pipeline: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 }}

Example Run Azure Pipeline on alternative host to dev.azure.com

spec:
  #[...]
  steps:
    - id: runAzurePipeline
      name: Run Pipeline
      action: azure:pipeline:run
      input:
        #[...]
        host: 'AZURE_DEVOPS_HOST'

Example using the User Token using azure:pipeline:run action

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

Example running a pipeline on a branch using the azure:pipeline:run action

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

Example running a pipeline with template parameters using the azure:pipeline:run action

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

Readme

Keywords

none

Package Sidebar

Install

npm i @backstage-community/plugin-scaffolder-backend-module-azure-devops

Weekly Downloads

259

Version

0.8.1

License

Apache-2.0

Unpacked Size

33.1 kB

Total Files

12

Last publish

Collaborators

  • patriko