'uses' statement to access multiple repositories

Viewed 24

I'm trying to create a pipeline for dependency management tool Renovate:

# Runs the renovate bot on a schedule.
# Adapted from: https://blog.objektkultur.de/how-to-setup-renovate-in-azure-devops/

schedules:
  - cron: "0 5 * * *"
    displayName: "Every day at 7am"
    branches:
      include:
        - main
        - master
    always: true

trigger: none

pool:
  vmImage: ubuntu-latest

variables:
  - group: "renovatebot"

steps:
  - checkout: self
    persistCredentials: true
    fetchDepth: 1
    
  - bash: |
      git config --global user.email 'bot@renovateapp.com'
      git config --global user.name 'Renovate Bot'
      echo "TOKEN = $TOKEN"
      echo "GITHUB_COM_TOKEN = $GITHUB_COM_TOKEN"
      npx renovate
    env:
      TOKEN: $(System.AccessToken)
      GITHUB_COM_TOKEN: $(githubtoken) # get a token from https://github.com/settings/tokens and save it in the 'renovatebot' variables group
      #RENOVATE_CONFIG_FILE: "./pipelines/renovate/config.js" # use this environment variable if you prefer to have the renovate pipeline definition and the config file in it's own dictionary instead of the repository root.

It uses the System.AccessToken to run GIT commands. This works for a single repo, but i'm trying to incorporate another repository into the same pipeline - i'm getting the following error however:

ERROR: Repository is not found (repository=[REDACTED]/[REDACTED])

This leads me to believe there is some auth issues accessing the second repository.

Reading through https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/azure-repos-git?view=azure-devops&tabs=yaml#protect-access-to-repositories-in-yaml-pipelines Then leads me to the 'uses' statement:

steps:
- checkout: git://FabrikamFiber/FabrikamTools # Azure Repos Git repository in the same organization
- script: # Do something with that repo
# Or you can reference it with a uses statement in the job
uses:
  repositories: # List of referenced repositories
  - FabrikamTools # Repository reference to FabrikamTools
steps:
- script: # Do something with that repo like clone it

However, if i try that in azure, i'm getting an error:

enter image description here

What am i missing? what is the correct usage of the 'uses' statement?

1 Answers

what is the correct usage of the 'uses' statement?

To use the uses: statement, you need to define it at job level.

For example:

jobs:
  - job: test
    uses:
     repositories:
       - test
    steps:
      - script:xxx

For more detailed info, you can refer to this doc: jobs.job definition

Related