Forum Discussion
How to register an azure pipeline from a Github Repository using Azure Devops API
Hello!
I'm working on automating Azure Pipeline registrations. (to work similarly to GitHub actions)
Our scenario is:
- Our repositories are located on Github
- Yes, the service connection is there. I can use it normally from Azure DevOps Web
- Our pipeline definition is located in a file in the path automation/pipeline.yaml for each repository.
The question is, how I can use the Azure Devops API to do it?
I'm checking the documentation here: https://learn.microsoft.com/en-us/rest/api/azure/devops/pipelines/pipelines/create?view=azure-devops-rest-7.0
But I didn't find anything relevant. The descriptions of the parameters don't say much about how to configure the repository etc. Am I missing any necessary documentation? Any directions on how to do it?
1 Reply
Take this as workaround by using Azure CLI + Script:
1. Install Azure DevOps CLIaz extension add --name azure-devops
2. Authenticate and Set Contextaz devops configure --defaults organization=https://dev.azure.com/YourOrg project=YourProject
3. Create Pipeline from GitHub Repoaz pipelines create \ --name "MyPipeline" \ --repository "https://github.com/YourOrg/YourRepo" \ --branch "main" \ --yml-path "automation/pipeline.yaml" \ --repository-type github \ --service-connection "GitHubServiceConnectionName"
It can:
• Links the pipeline to your GitHub repo
• Points to the YAML file
• Uses the existing service connection