Azure / pipelines

Enable GitHub developers to trigger Azure Pipelines from a GitHub Actions workflow
MIT License
73 stars 83 forks source link

How to link Azure DevOps pipeline with GitHub repo #13

Open eric-labelle opened 4 years ago

eric-labelle commented 4 years ago

Hi, I'm trying to configure a workflow on a GitHub project using the Azure/pipeline@v1 action and facing a problem. I can successfully trigger the pipeline in Azure DevOps, but it always checkout the master branch from github rather than the PR opened. I can see the log is trigger from the following: https://github.com/Azure/pipelines/blob/master/src/pipeline.runner.ts#L82 but it is unclear how I can do the link suggested by the comment on line 76

// If definition is linked to existing github repo, pass github source branch and source version to build.

My pipeline on DevOps uses multiple checkout (self and a github repo using a GitHubServiceConnection) and is hosted in a DevOps repository.

Thanks for you help.

ionutleca commented 4 years ago

Looks like definition is linked to existing Github repo means that your az pipeline yaml is in the same Github repository as your action. Since that is not the case, when triggered, the pipeline will just pull whatever the default branch is set up to. (master in this case)

In your case, one option would be to send the commit id from your git workflow to the az pipeline as a run time variable and use it in a checkout step in the pipeline.

https://github.com/Azure/pipelines/pull/11 has the variables feature you can use.

eric-labelle commented 4 years ago

Yeah, that was the only logical explanation I came up with but I just don't see the point of the Azure/pipeline@v1 action then.

Quite confusing all that I must say. Too much links in both ways. Or perhaps it's just my usecase that's special. Because the pipeline is defined in a repo in Azure, and this repo has a submodule that's hosted on github and will be open-sourced. I need to be able to trigger the Azure pipeline and make sure the github submodule checkout the sha of the opened PR that triggered this azure pipeline

ionutleca commented 4 years ago

A cleaner solution for your scenario would be the one described here https://github.com/microsoft/azure-pipelines-yaml/issues/291

Unfortunately it seems that the pipeline resource triggers are not working as expected yet :(

thesattiraju commented 3 years ago

@ionutleca is this still a valid scenario for you?

ionutleca commented 3 years ago

@ds-ms I didn't invest any more time into moving to GitHub actions from AzureDevOps, so no. But I think that anyone that has to make this transition, will need these basic features (pass variables, select target branch, etc.)