<p>Yes; you can use the <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&amp;tabs=yaml" rel="nofollow noreferrer">Build.Reason pre-defined variable</a> in a task <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&amp;tabs=yaml" rel="nofollow noreferrer">condition</a>, like this for example:</p>
<pre><code>condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
</code></pre>

CC BY-SA 4.0
2021-12-16T16:25:54.047Z
2021-12-16T16:25:54.047Z
Vince Bowdren
<p>Need to create a YAML based azure build pipeline i.e, need to run particular tasks like only build step when it is PR automated and when the same pipeline  manually run it should run build task along with archive and publish artifact tasks</p>

<azure-devops><azure><azure-pipelines><build-pipeline><yaml>
YAML based azure build pipeline to run particular tasks based on condition?
nova world
# YAML based azure build pipeline to run particular tasks based on condition?

(Asked by: username_0 on 2021-08-13)

Need to create a YAML based azure build pipeline i.e, need to run particular tasks like only build step when it is PR automated and when the same pipeline manually run it should run build task along with archive and publish artifact tasks

**Tags:** azure-devops, azure, azure-pipelines, build-pipeline, yaml


---

## 1 answers

### Answer by username_1 on 2021-12-16. Score: 1

Yes; you can use the Build.Reason pre-defined variable in a task condition, like this for example:
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))


---

