definizione resources.repository.repository

La repository parola chiave consente di specificare un repository esterno. Usare una risorsa del repository per fare riferimento a un repository aggiuntivo nella pipeline.

repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  trigger: none | trigger | [ string ] # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos).
  name: string # repository name (format depends on 'type'; does not accept variables).
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires.
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  trigger: none | trigger | [ string ] # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos).
  name: string # repository name (format depends on 'type'; does not accept variables).
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires. Does not accept variables.
repositories:
- repository: string # Required as first property. Alias for the repository.
  endpoint: string # ID of the service endpoint connecting to this repository.
  name: string # repository name (format depends on 'type'; does not accept variables).
  type: string # Type of repository: git, github, githubenterprise, and bitbucket.
  ref: string # ref name to checkout; defaults to 'refs/heads/main'. The branch checked out by default whenever the resource trigger fires. Does not accept variables.

Definizioni che fanno riferimento a questa definizione: resources.repository

Proprietà

repository Stringa. Obbligatorio come prima proprietà.
Alias per il repository specificato. Valori accettabili: [-_A-Za-z0-9]*.

endpoint Stringa.
ID dell'endpoint di servizio che si connette a questo repository.

triggertrigger.
Trigger CI per questo repository, nessun trigger CI se omesso.

Importante

  • I trigger delle risorse del repository sono supportati solo per Azure Repos repository Git.
  • I trigger delle risorse del repository non supportano batch.

name Stringa.
Nome del repository. Il formato dipende da 'type'; non accetta variabili.

ref Stringa.
ref name to checkout; impostazione predefinita su 'refs/heads/main'. Il ramo estratto per impostazione predefinita ogni volta che viene attivato il trigger della risorsa. Le espressioni di modello sono supportate.

ref Stringa.
ref name to checkout; impostazione predefinita su 'refs/heads/main'. Il ramo estratto per impostazione predefinita ogni volta che viene attivato il trigger della risorsa. Non accetta variabili.

type Stringa.
Tipo di repository: git, github, githubenterprise e bitbucket.

Commenti

Importante

La risorsa repository non consente le variabili della pipeline in name e ref. I caratteri jolly sono supportati nei trigger.

Le espressioni modello sono supportate per la ref proprietà , ma non per la name proprietà . I caratteri jolly sono supportati nei trigger.

Importante

I trigger di risorse del repository sono supportati solo per Azure Repos repository Git. Per altre informazioni sulla trigger sintassi, incluso il supporto con caratteri jolly per rami e tag, vedere Definizione dei trigger e Compilazione Azure Repos repository Git o TFS.

Importante

batch non è supportato nei trigger delle risorse del repository.

Se la pipeline dispone di modelli in un altro repository, è necessario informare il sistema su tale repository.

Se la pipeline dispone di modelli in un altro repository o se si vuole usare il controllo multi-repository con un repository che richiede una connessione al servizio, è necessario informare il sistema su tale repository.

Tipi

Le pipeline supportano i valori seguenti per il tipo di repository: git, githube bitbucket. Il git tipo fa riferimento a Azure Repos repos Git.

  • Se si specifica type: git, il name valore fa riferimento al nome di un repository Git di Azure Repos.

    • Se la pipeline si trova nello stesso progetto Azure DevOps del repository, ad esempio un repository denominato tools, lo si fa riferimento usando name: tools.
    • Se la pipeline si trova nella stessa organizzazione di Azure DevOps del repository, ma in un progetto Azure DevOps diverso, ad esempio un progetto denominato ToolsProject, è necessario qualificare il nome del repository con il nome del progetto: name: ToolsProject/tools.
  • Se si specifica type: github, il name valore è il nome completo del repository GitHub e include l'utente o l'organizzazione. Un esempio è name: Microsoft/vscode. I repos di GitHub richiedono una connessione al servizio GitHub per l'autorizzazione.

  • Se si specifica type: bitbucket, il name valore è il nome completo del repository Bitbucket Cloud e include l'utente o l'organizzazione. Un esempio è name: MyBitbucket/vscode. I repos di Bitbucket Cloud richiedono una connessione del servizio Cloud Bitbucket per l'autorizzazione.

Per altre informazioni su questi tipi, vedere Consultare più repository nella pipeline - Definizione della risorsa repository.

Variabili

In ogni esecuzione i metadati per una risorsa di repository sono disponibili per tutti i processi sotto forma di variabili di runtime. L'identificatore <Alias> assegnato per la risorsa del repository.

resources.repositories.<Alias>.name
resources.repositories.<Alias>.ref
resources.repositories.<Alias>.type
resources.repositories.<Alias>.id
resources.repositories.<Alias>.url
resources.repositories.<Alias>.version

Nell'esempio seguente è disponibile una risorsa repository con un alias di commone le variabili di risorsa del repository sono accessibili usando resources.repositories.common.*.

resources:
  repositories:
    - repository: common
      type: git
      ref: main
      name: Repo

variables:
  ref: $[ resources.repositories.common.ref ]
  name: $[ resources.repositories.common.name ]
  id: $[ resources.repositories.common.id ]
  type: $[ resources.repositories.common.type ]
  url: $[ resources.repositories.common.url ]
  version: $[ resources.repositories.common.version ]

steps:
- bash: |
    echo "name = $(name)"
    echo "ref = $(ref)"
    echo "id = $(id)"
    echo "type = $(type)"
    echo "url = $(url)"
    echo "version = $(version)"

Variabili

In ogni esecuzione i metadati per una risorsa di repository sono disponibili per tutti i processi sotto forma di variabili di runtime. L'identificatore <Alias> assegnato per la risorsa del repository.

resources.repositories.<Alias>.name
resources.repositories.<Alias>.ref
resources.repositories.<Alias>.type
resources.repositories.<Alias>.id
resources.repositories.<Alias>.url

Nell'esempio seguente è disponibile una risorsa repository con un alias di commone le variabili di risorsa del repository sono accessibili usando resources.repositories.common.*.

resources:
  repositories:
    - repository: common
      type: git
      ref: main
      name: Repo

variables:
  ref: $[ resources.repositories.common.ref ]
  name: $[ resources.repositories.common.name ]
  id: $[ resources.repositories.common.id ]
  type: $[ resources.repositories.common.type ]
  url: $[ resources.repositories.common.url ]

steps:
- bash: |
    echo "name = $(name)"
    echo "ref = $(ref)"
    echo "id = $(id)"
    echo "type = $(type)"
    echo "url = $(url)"

Esempi

resources:
  repositories:
  - repository: common
    type: github
    name: Contoso/CommonTools
    endpoint: MyContosoServiceConnection

Vedere anche