Can't access URLs in Slack messages from draft deploys

When I create a draft post in a Jekyll site then I usually get a Slack message when it is done. This URL however does not work. Reading another post it appears that the URL is too long so isn’t valid, but I don’t see an option in NetlifyCMS to specifiy the branch structure to make it shorter. Is this possible?

Hi @typhoon_2099 and welcome to the community!
Do you mean the cms/<collection>/<entry_slug> branch name when working with editorial workflow?
Which URL are you referring to? The preview URL - that one should contain only the PR number (when hosting on Netlify).
You can control just the <entry_slug> part of the branch name by specifying Configuration Options | Netlify CMS | Open-Source Content Management System but that has the side effect of changing the filename.

Changing the file name is not possible in Jekyll, it depends on the file to follow the ‘{{year}}-{{month}}-{{day}}-{{slug}}’ format when building the site. I do indeed mean the preview URL, we currently get Netlify subdomain URLs sent in the Slack message. I don’t think I can turn that off without also turning off branch deploys.

Can you share how the Slack message looks like?
I’ve just set up an incoming webook and this how it looks:
image
And it links to: https://deploy-preview-177--blissful-newton-8cd25e.netlify.app/
I don’t see the branch name in the URL.
What am I missing here?

Screenshot from 2020-04-22 12-47-40 leads to the non-existent https://cms-blog-2020-04-21-continious-improvement-with-a-peace-lily–mesomorphic.netlify.app/

For some reason your recent posts were marked for review and I had to approve them as not spam…
I’ll get someone with more experience with the slack integration to comment as this seems less of a CMS issue.

Hey @typhoon_2099,

Each label within a URL is limited to 63 characters so your earlier assessment was correct. I also appreciate that Jekyll is pretty stringent about the YYYY-MM-DD prefix. Our branch structure is also pretty stringent, too.

Honestly – I think that the path of least resistance here would be to reassess the post title and/or slug. Without too much damage, could you adopt a different slug or could the post title be revised?

Our label, cms-blog-2020-04-21-continious-improvement-with-a-peace-lily--mesomorphic, is 73 characters long.

cms-blog-2020-04-21-cont-imp-with-a-peace-lily--mesomorphic is a measly 59 characters and, as such, I’d expect it to work.

I’ll try to add something to allow for providing a short URL, though I’ll also have to make sure that I can still use the original slug as a fallback if no shorter URL is provided.

As I say, the filename is used to create the URL for the post, and NetlifyCMS bases the file name off of the title. It would be nice to not have to specify a new title every time. What would help is a way to specify the branch name format for editorial workflows, that way we could format it to something that stays under 63 characters.

A small update - I noticed this happens when choosing to run deploys for all branches.
Since the CMS always creates a PR I got two slack messages - one with the branch name and one with the PR number (which is shorter).

I only receive the branch deploy message, I don’t get one for the PR. Is this related to using BitBucket as the backend for editorial workflows (currently in beta according to the docs). We still use branch deploys for other site tweaks so I don’t think we can turn them off permanently, but I could try turning them off temporarily to see if we still get build messages.

Thanks @typhoon_2099 for the additional information - that is very helpful. I tested with git-gateway + GitHub. I’ll try to setup with Bitbucket and see what happens.
Found this [Support Guide] Bitbucket PR deploy previews fail that might be related.

That post seems to be discussing failed builds. Our builds aren’t failing, though now that I think about it, I don’t think I’ve ever seen a Netlify build triggered from a pull request before…

By default the hook is set up only for repository push:


You could try setting to pull requests too which will probably float the issue I mentioned:

It;s already set up for Pull Request Created/Updated:

Hmm, I changed my web hook settings to match yours and it looks like PRs are completely ignored which makes sense if they are bound to fail.

So is my take away from this that I have to go into Netlify and find the commit URL to post into Slack on Netlify’s behalf? Currently it sounds like Branch builds for NetlifyCMS when using Jekyll is broken, and PR webhook builds are broken.

to be clear - PR webhook builds triggered by bitbucket are broken by Atlassian, not by Netlify :slight_smile:

https://jira.atlassian.com/browse/BCLOUD-5814

…is the 7.5 year old feature request that they have clearly decided not to implement to enable them.

I don’t particularly care about PR builds, I care about the Slack messages we get when builds are completed. Since the branch name breaks the URL, is there a way to send the commit URL through the Slack message instead? As I say, the URL that is in the Slack message is broken, but if I log into Netlify and check the deploy logs I can get a working URL that just uses the commit ID.

Hi @Scott I have tried messing around with the NetlifyCMS settings to allow us to provide separate paths and file names but to no avail. We need the longer paths as part of our SEO, and there’s no way to shorten them that doesn’t affect that. I don’t see why Netlify can’t just trim the domain label down to 63 characters, or at least provide the Slack notification with the commit id URL that I can get from the deploys page. I currently have to go and get that URL and post it to Slack manually, and since I won’t be around from next week I will have to get someone else here to start working around this issue.

Hey @typhoon_2099,

The reason we can’t truncate this is because it could put us in a position where domain names aren’t unique. Let’s assume you create two posts on the same day, “2020-04-04-this-is-a-blog-article-about-something-interesting-part-1” and “2020-04-04-this-is-a-blog-article-about-something-really-interesting-part-2”… it’s going to 404 and cause some serious headache!

Realistically, this is a bigger issue than “the link to the PR in Slack doesn’t work”. Offering a URL with the unique commit ID isn’t a bad idea and I would definitely forward this as a feature for this use case. But, again, it’s an engineering-time-heavy workaround. At its core, the framework which you are using isn’t validating the URLs which it itself is creating. In my eyes, there’s 3 (maybe 4) solutions (and they’re listed in order of feasibility):

  • Revise the URLs being used. I know that this may suck for SEO in the short term but it’s a definite workaround (in this example, could CI replace continuous improvement)?
  • Raise an issue with the framework to manage 63 character label limits (which would require some code and thought about how to handle the scenario in paragraph 1 of this response)
  • Raise a feature with us to offer a commit ID-driven URL through the Slack webhook (though I will admit that this is highly unlikely to be added to a backlog any time soon, if at all)

If it’s out there, there may be a third party solution which offers the customisation we need here to make it work. Again, a bandaid but it’s enough to get you going.

I know that this perhaps isn’t the answer you were looking for however I’m happy to discuss it further and/or get a feature request up here at Netlify.