I'm trying to get a single pipeline to handle the full CI/CD for internal NuGet Package Projects. The issue I'm running into is finding a way to exclude the NuGet publish steps for the verification builds in a pull request. Is there a way to identify that the build was triggered as a pull request verification build?
I've gone as far as to set a third branch (master -> release; pre-release -> alpha; develop doesn't publish) but unless I require developers to branch off of develop and do a pull request into it I'm still having the same issue. And even then the pull request from develop to pre-release and pre-release to release still have the issue unless I remove the verification build from the pull request. Which I don't want to have to do.
I've used the msdn provided branch conditions, but they don't help on pull request verification builds.
The verification build ends up publishing the version before the code review, then the subsequent build from the merge fails because the version already exists.
In the custom condition of the publish task put this:
and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
Now the task not will be executed if the build is a verification build during the PR.