Run a build step only if we’re building the master branch (when using visual pipelines)

Use eq(variables['Build.SourceBranch'], 'refs/heads/master') for Control Options -> Run this task -> Custom conditions

– via Microsoft Docs