Azure pipeline to build public github project, pipeline yaml stored in Azure Devops Git

1.1k Views Asked by At

I want to create a pipeline which builds and packages a public/opensource codebase from a public github repo. I don't want to store the pipeline yaml definition github, I want this in my private Azure Devops repo.

Basically I want the pipeline to:

  • clone the public git repo
  • perform a build
  • do some configuration and packaging
  • deploy it

It seems like Azure yaml pipelines expect the pipeline yaml and code to exist in the same repository. I see tasks types to download a "GitHub Release", but nothing to just generically clone a git repo. Am I missing it?

1

There are 1 best solutions below

1
On BEST ANSWER

To save the Pipeline Yaml file in Private Azure DevOps repo and use repo from Github, you need to reference multiple repo resouces in YAML.

Here are two methods you can refer to:

You can add the Repo Resource in YAML pipeline to use the repo in Github. Refer to this doc:Check out multiple repositories in your pipeline

For example:

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

steps:
- checkout: self
- checkout: MyGitHubRepo

- script: dir $(Build.SourcesDirectory)

Or you can add a step to run the git clone command to clone the public git repo.

steps:
- script: git clone RepoURL
  displayName: 'Clone Github Repo'

- other tasks to build the project

In this case, the YAML file will be saved in Azure Repo. And the Github Repo will be checked out during the pipeline run.