renovate/lib/modules/platform/azure
Rhys Arkins e27fe66980
feat(git): cloneSubmodulesFilter (#33115)
2024-12-18 13:01:14 +00:00
..
__snapshots__ refactor: rename platformOptions -> platformPrOptions (#30173) 2024-07-16 07:33:55 +00:00
azure-got-wrapper.spec.ts test(perf): improve test speed (#24323) 2023-09-08 11:40:04 +00:00
azure-got-wrapper.ts fix(platform/azure): Allows azure-got-wrapper to retry requests following connection failures (#24348) 2023-09-12 01:08:07 +00:00
azure-helper.spec.ts fix(azure): paginate getTeams() (#29060) 2024-05-14 10:18:02 +00:00
azure-helper.ts chore: eslint to enforce for typed imports (#30844) 2024-08-19 13:15:27 +00:00
index.spec.ts fix(azure): update cache after PR create or update (#31766) 2024-10-03 07:39:42 +00:00
index.ts feat(git): cloneSubmodulesFilter (#33115) 2024-12-18 13:01:14 +00:00
readme.md feat(platform/azure): implement automergeStrategy for Azure DevOps platform (#26429) 2023-12-27 09:17:03 +00:00
schema.ts refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
types.ts refactor: convert enums to unions (#18900) 2022-11-20 07:34:23 +00:00
util.spec.ts refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
util.ts chore: eslint to enforce for typed imports (#30844) 2024-08-19 13:15:27 +00:00

readme.md

Azure DevOps and Azure DevOps Server

Authentication

First, create a Personal Access Token for the bot account. Let Renovate use your PAT by doing one of the following:

  • Set your PAT as a token in your config.js file
  • Set your PAT as an environment variable RENOVATE_TOKEN
  • Set your PAT when you run Renovate in the CLI with --token=

Permissions for your PAT should be at minimum:

Scope Permission Description
Code Read & Write Required
Work Items Read & write Only needed for link to work item

Remember to set platform=azure somewhere in your Renovate config file.

Running Renovate in Azure Pipelines

Setting up a new pipeline

Create a brand new pipeline within Azure DevOps, and select your source: Azure DevOps create new pipeline{ loading=lazy }

Then select your repository.

Within Configure your pipeline select: Starter pipeline Azure DevOps starter pipeline template{ loading=lazy }

Replace all content in the starter pipeline with:

schedules:
  - cron: '0 3 * * *'
    displayName: 'Every day at 3am (UTC)'
    branches:
      include: [main]
    always: true

trigger: none

pool:
  vmImage: ubuntu-latest

steps:
  - task: npmAuthenticate@0
    inputs:
      workingFile: .npmrc

  - bash: |
      git config --global user.email 'bot@renovateapp.com'
      git config --global user.name 'Renovate Bot'
      npx --userconfig .npmrc renovate      
    env:
      RENOVATE_PLATFORM: azure
      RENOVATE_ENDPOINT: $(System.CollectionUri)
      RENOVATE_TOKEN: $(System.AccessToken)

Create a .npmrc file

Create a .npmrc file in your repository:

registry=https://pkgs.dev.azure.com/YOUR-ORG/_packaging/YOUR-FEED/npm/registry/
always-auth=true

For the registry key, replace YOUR-ORG with your Azure DevOps organization and YOUR-FEED with your Azure Artifacts feed.

Create a config.js file

Create a config.js file in your repository:

module.exports = {
  hostRules: [
    {
      hostType: 'npm',
      matchHost: 'pkgs.dev.azure.com',
      username: 'apikey',
      password: process.env.RENOVATE_TOKEN,
    },
  ],
  repositories: ['YOUR-PROJECT/YOUR-REPO'],
};

For the repositories key, replace YOUR-PROJECT/YOUR-REPO with your Azure DevOps project and repository.

Yarn users

To do a successful yarn install you need to match the URL of the registry fully. Use the matchHost config option to specify the full path to the registry.

module.exports = {
  platform: 'azure',
  hostRules: [
    {
      matchHost:
        'https://myorg.pkgs.visualstudio.com/_packaging/myorg/npm/registry/',
      token: process.env.RENOVATE_TOKEN,
      hostType: 'npm',
    },
    {
      matchHost: 'github.com',
      token: process.env.GITHUB_COM_TOKEN,
    },
  ],
  repositories: ['YOUR-PROJECT/YOUR-REPO'],
};

Put this in your repository's .npmrc file:

registry=https://myorg.pkgs.visualstudio.com/_packaging/myorg/npm/registry/
always-auth=true

Add renovate.json file

Additionally, you can create a renovate.json file (which holds the Renovate configuration) in the root of the repository you want to update. Read more about the Renovate configuration options

Using a single pipeline to update multiple repositories

If you want to use a single Renovate pipeline to update multiple repositories you must take the following steps.

Add the names of the repositories to config.js. Make sure that the "Project Collection Build Service (YOUR-PROJECT)" user has the following permissions on the repositories:

  • Contribute
  • Contribute to pull requests
  • Create branch
  • Read

The user must have the following permission at Project-level:

  • View project-level information

Linking a work item to the Pull Requests

If you want Renovate to automatically link an existing work item to the Pull Requests, you can set the azureWorkItemId configuration. Make sure the user has the following permissions on the work item's area path:

  • Edit work items in this node
  • View work items in this node

If the user does not have these permissions, Renovate still creates a PR but it won't have a link to the work item.

Adding tags to Pull Requests

Tags can be added to Pull Requests using the labels or addLabels configurations. If the tag does not exist in the DevOps project, it will be created automatically during creation of the Pull Request as long as the user has the permissions at Project-level:

  • Create tag definition

Otherwise, when a tag does not exist and the user does not have permission to create it, Renovate will output an error during creation of the Pull Request.