Roh
Roh

Reputation: 321

Passing variable into YAML file

I am trying to pass a variable to a pr trigger depending on what branch I want to create a pull request with. Is it possible to pass different variables when the pipeline runs automatically. Or do I have to manually trigger the pipeline with a new variable before running it?

My YAML snippet with the variables **YAML SNIPPET**

Upvotes: 2

Views: 972

Answers (1)

Mengdi Liang
Mengdi Liang

Reputation: 18958

According to the screenshot you shared in the question, seems the source of this YAML pipeline is one of your Azure Devops Repos.

But, according the doc YAML PR trigger:

YAML PR triggers are only supported in GitHub and Bitbucket Cloud.

enter image description here

For Azure Devops repos source, the YAML pipeline triggered by PR can only be achieved by Build policy. If you don't specify the build policy and just use pr in YAML, it will not work.


pass a variable to a pr trigger depending on what branch I want to create a pull request with.

Why not directly to use the pre-defined variable which can let the YAML know what branch that the pull request created with:

System.PullRequest.SourceBranch : The branch that is being reviewed in a pull request.

System.PullRequest.TargetBranch: The branch that is the target of a pull request.

Upvotes: 2

Related Questions