Bitbucket tags trigger branch deploy

Hello,

I’m really satisfied with your services except one thing. I have my site to deploy any branch pushed into Bitbucket repository but when I tag some commit with git tag (eg. v1.2.3) Bitbucket notifies Netlify about new push and Netlify treats that as new branch and tries to deploy it. The problem is that it always fails because Netlify buildbot tries to find refs/heads/v1.2.3 which for git tags isn’t correct (it is refs/tags/v1.2.3).
Of course it isn’t much big deal but since I have connected Netlify into Slack for failed build notifications, it starts to be annoying.

Is there anything to do to resolve it? I understand that it would be best if Bitbucket woudn’t notify Netlify on tag creation but unfortunatelly it’s not possible to set up.

Thank you for any advice in advance.

Best regards,

Lukáš Krotovič
Web developer in HoppyGo

Hello @HoppyGo, welcome to the community.

So, it looks like bitbucket treats pushing a new tag like any other push. As far as our buildbot is concerned, it’s just another commit. In any case, you likely could use https://docs.netlify.com/configure-builds/file-based-configuration/#ignore-builds to check if the latest push was for a tag and if so, return a non-zero exit code. This would tell our buildbot to go ahead and skip the build.

I’m not sure what that exact git command would be but that could be a possible method prevent tags from triggering a build from our end, since bitbucket doesn’t treat those in a unique way.

Hello @Dennis,

thank you for the advice. It might be usable but I have one concern about that command.
I have googled that this should do it git show-ref --quiet --verify -- "refs/heads/$BRANCH" but would your buildbot replace the environment variable BRANCH?

Our buildbot should respect that env var. You can see that variable mentioned here: https://docs.netlify.com/configure-builds/environment-variables/#read-only-variables. Let me know how it goes.