Nayden Van
Nayden Van

Reputation: 1569

Azure Pipeline configurations

I am facing a problem that is confusing me a bit and I would like to find the best approach to avoid to repeat my pipelines.

in this GitHub repos I have my yaml file to build the project, and this yaml targets a folder template on which it runs the C# Build and Publish. Approximately the GitHub repo is structure as follow:

- Folder 1
- Folder 2
- Folder 3
- Azure-Pipelines(build and Publish)
- Azure-pipeline.yaml

During the pipeline run, my yaml targets the Àzure-Pipelines(Build and Publish) folder and build the project. This is my Azure-pipeline.yaml file

stages:
- stage: Build
  displayName: 'Build'
  jobs:  
  - template: Azure-Pipelines/build.yaml
    parameters:
      solution: 'Solution-to-build'

- stage: Publish
  displayName: 'Release and Push'
  jobs:  
  - template: Azure-Pipelines/publish.yaml
    parameters:
      <All the parameters configured for this yaml file>

The template and the structure of my GitHub, keeps repeating themselves, as in each gitrepo I have that Azure-pipeline folder. What I am trying to to. Is to have a GitHub repo Where I keep the build.yaml and publish.yaml. and make all the other repos refer to this folder when the pipeline runs.

Is there any way how I can achieve this?

Please if I am missing any details to make my point clear, just ask. Thank you so much in advance

Upvotes: 0

Views: 178

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35514

Is there any way how I can achieve this?

You could try to use the Resources in YAML Pipeline.

Here are the steps:

Step1: Create a Github Service Connection in Project Settings -> Service connection .

Step2: You could try to use the following sample to use the yaml template from another Github Repo.

Example

resources:
  repositories:
  - repository: MyGitHubRepo # The name used to reference this repository in the checkout step
    type: github
    endpoint: serviceconnectionname
    name: githuborg/reponame   #e.g. yy/test
    ref: main

pool:
  vmImage: ubuntu-latest

stages:
- stage: Build
  displayName: 'Build'
  jobs:  
  - template: Azure-Pipelines/build.yml@MyGitHubRepo

Upvotes: 2

Related Questions