Azure pipeline - specify branch name in multiple repository
M

2

6

As a continuation to Azure DevOps - Handling single release for separate code repositories for UI and Dotnet API layer I am trying to proceed with checking out multiple repos in my yaml by defining it under repositories as shows below. I am unable to understand where to change the branch to make sure, my tasks such as checkout does not happen on master, but on my custom branch.

resources: 
repositories:
  - repository: mybitbucketrepo
    type: bitbucket
    endpoint: myserviceconnection
    trigger:  # CI trigger for this repository, no CI trigger if skipped (only works for Azure Repos)
      branches:
        include: [ custom-branch ]
    name: orgname/reponame

What I tried so far is below for which I get the error - Only 'self', 'none' or a repository alias are supported. Any help will be appreciated.

- checkout: mybitbucketrepo@custom-branch
Mckissick answered 26/11, 2020 at 7:31 Comment(0)
U
14

You need to define ref settings:

When using a repository resource, specify the ref using the ref property. The following example checks out the features/tools/ branch of the designated repository.

resources:
  repositories:
  - repository: MyGitHubRepo
    type: github
    endpoint: MyGitHubServiceConnection
    name: MyGitHubOrgOrUser/MyGitHubRepo
    ref: features/tools

and then just

steps:
- checkout: MyGitHubRepo
Unpolitic answered 26/11, 2020 at 8:50 Comment(0)
H
2

IT's not support to use @, please use inline ref syntax

steps:
 - checkout: self
 - checkout: git://MyProject/MyToolsRepo@features/mytools

By appending @<ref>, the agent can be instructed to check out a different ref. In this case, it's assumed to be a branch called features/mytools. Branches can also be prefixed with refs/heads/ to make it unambiguous that it's a branch.

Other valid refs (and ref-like things):

  • refs/tags/
  • commit ID

For more details, please take a look at this link: Multi-checkout: checking out multiple repos

You could also define it in resource, check our official doc --Checking out a specific ref A sample as below:

resources:
  repositories:
  - repository: app
    type: github
    name: org1/repoA
    ref: master
    endpoint: 'GitHub endpoint'
    trigger:
    - master
    - release/*
Hebrides answered 26/11, 2020 at 10:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.