sentry-netlify-build-plugin
sentry-netlify-build-plugin copied to clipboard
Gitlab - SentryCLI failed to set commits
When using this plugin with a Gitlab integration, we run in to the following error:
12:51:09 PM: cmd: '/opt/buildhome/.netlify-build-plugins/node_modules/@sentry/cli/sentry-cli releases set-commits ac28e1c49ac9312242e09696c2046c53c3926835 --commit theworkshop/web-app@ac28e1c49ac9312242e09696c2046c53c3926835'
12:51:09 PM: }
12:51:09 PM:
12:51:09 PM: ┌──────────────────────────────────────────────┐
12:51:09 PM: │ Plugin "@sentry/netlify-build-plugin" failed │
12:51:09 PM: └──────────────────────────────────────────────┘
12:51:09 PM:
12:51:09 PM: Error message
12:51:09 PM: Error: SentryCLI failed to set commits. You likely need to set up a repository or repository integration.
12:51:09 PM: Read more: https://docs.sentry.io/workflow/releases/?platform=python#install-repo-integration
When running the command locally to replicate the issue, we get a bit more information around why this is failing:
$ sentry-cli releases set-commits ac28e1c49ac9312242e09696c2046c53c3926835 --commit theworkshop/web-app@ac28e1c49ac9312242e09696c2046c53c3926835
error: Unknown repo 'theworkshop/web-app'
The error we're running into seems to be due to how whitespace is handled in the repository name with the Gitlab integration
Modifying the command locally to the following fixes the issue:
$ sentry-cli releases set-commits ac28e1c49ac9312242e09696c2046c53c3926835 --commit theworkshop\ /\ web-app@ac28e1c49ac9312242e09696c2046c53c3926835
It should also probably be documented somewhere that the what Sentry uses as 'name' is actually configurable on Gitlab - i.e. if a user has modified their repo name with Gitlab, then this script won't work as this script actually uses the repo 'slug' rather than name for matching.
Just to add a comment on a potential 'fix' until I have chance to look at this in any more detail.
https://github.com/getsentry/sentry-netlify-build-plugin/blob/master/index.js#L110 could be edited to the following, you'd probably want a bit more of a definitive check however:
const repositoryParts = process.env.REPOSITORY_URL.split(/[:/]/).slice(-2)
const repository = process.env.REPOSITORY_URL.includes('gitlab') ? repositoryParts.join(' / ') : repositoryParts.join('/')
I assume other people using Gitlab are experiencing this issue - it would be good to have more evidence of this though!
Yes I can confirm I'm having the same issue too. It would be nice to see it addressed.
I'm having the same issue, though using a Github repository.
Same issue with a private github repo.
Same issue with a private Github repo. The weird thing is that it works correctly for the first time today (which I implemented), but then it doesn't work anymore. I didn't make any even a change in the implementation.
Same issue with a private github repo. Worked for the first commit and the stopped working due to the 'SentryCLI failed to set commits.' error.
I was able to get it working, however the article by @jonesphillip needs updated to state that private repos need to enable GitHub integrations.
Settings > Integrations > GitHub > Add Installation
After the integration was installed I then had to add the specific repo under the installed GitHub integrations under the 'Configurations' tab using the 'Add Repository' dropdown button.
I had the same issue, this is how I solved it :
Settings > my-org > Integrations > GitHub
Then make sure your private repository is listed in the configuration. Then re-build on Netlify.
(Thanks @tysonmatanich for pointing me in the right direction.)
I have the same issue with Gitlab. It worked on the first run, but fails on subsequent runs with an "unknown repo" error. The Sentry UI recognizes the repo with no issue and the release that did work shows commits.
@djw27 What did you end up doing?
I have the same issue with Gitlab. It worked on the first run, but fails on subsequent runs with an "unknown repo" error. The Sentry UI recognizes the repo with no issue and the release that did work shows commits.
@djw27 What did you end up doing?
@dunsworth we've left this as an unresolved issue on the back-burner - hopefully we'll get around coming up with a solution in the new year
@djw27 Any update on this issue. I am facing same issue with Gilab integration. If it is not fixed any possible workaround will be much appreciated. Thanks
@djw27 Any update on this issue. I am facing same issue with Gilab integration. If it is not fixed any possible workaround will be much appreciated. Thanks
@devs4522 no update yet I'm afraid - will post here when we get around to it
I have the same issue with a github private repo. Worked on first try but fails on subsequent runs. What's odd is that the Configure github tab shows non of the repos I authorized via the dropdown. I've tried this multiple times and when I try to Add Installation the sentry github app is already authorized yet its not reflected on the sentry UI.
Here's where it's erroring out.
9:28:55 AM: Error: Command failed: /opt/build/repo/.netlify/plugins/node_modules/@sentry/cli/sentry-cli releases set-commits b02f83cafc02ecba9f6583f29b5c9beab3b70b7a --commit xxx/yyy@b02f83cafc02ecba9f6583f29b5c9beab3b70b7a 9:28:55 AM: error: Unknown repo 'xxx/yyy'
I've obfuscated the repo url, but the issue is that the plugin should be attempting to commit to @xxx/yyy instead of xxx/yyy as it is a private repo.
Any pointers would be useful. Thanks
P.S - Also worth nothing that my Sentry org id is say xxx instead of @xxx. (Not sure if this has anything to do with the repo url)
I think I might be having the same problem
Is it dependent on having your github integrated with sentry first??
@jasikpark Yes you'll want to make sure you have your GitHub integration installed and the relevant repository added. You can find more information about that here: https://docs.sentry.io/product/releases/setup/release-automation/
Let me know if you're still having problems after that
@juanpprieto did you add your add your repository as well? You'll need to do that as an additional step after installing the integration. More information on that here: https://docs.sentry.io/product/releases/setup/release-automation/
That worked for me -- I thought I had already authorized it since I had a whole fun problem where I initially made an email authed account, and then installed the Github App on my Github account, which sent me to an account creation page with no "login instead" link, so I created another account with the same email.
This then meant that my original account was getting 401 errors when trying to load my projects page in the site, and I first just tried to use the new Github authed account, but I found out that I was setup with a legacy subscription due to signing up via the Github App, meaning I couldn't use newer features like the Performance section.
I then deleted that account, but that did not remove the GIthub App from my profile, which meant that when I saw a section claiming I needed Github auth, I thought I was good. Then I found https://help.sentry.io/product-features/integrations/github-why-can-t-i-add-a-repository/ and followed its recommendation, and my problems were solved at that point.
I still haven't actually received any error reports, even though I manually caused them, for example by calling foobar() in the terminal, but that's another story.
Even though SENTRY_REPOSITORY variable is set on Netlify its still not used when deploying
@VitalijusZimaitis that is because the version wasn't updated in Netlify plugins yet. See my comment here: https://github.com/getsentry/sentry-netlify-build-plugin/pull/46#issuecomment-1038620658
For anyone still having this issue
- Go to
Settings > Repositories - Copy the name on the top (if your repo is
gitlab.com/xxx/yyythen Sentry will show likeXxx / Yyy). - Go to Netlify > Build > Environment
- Create
SENTRY_REPOSITORYand set this value you copied
Enjoy ✨
Life saver @kasvith! Spent way too long on this – perhaps the readme should be updated to indicate the name needs to exactly match the text string displayed in the Sentry UI and is not actually the repository slug.
i have the same issue on private gitlab repo