Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Gitlab - SentryCLI failed to set commits #21

Open
djw27 opened this issue Aug 10, 2020 · 23 comments
Open

Gitlab - SentryCLI failed to set commits #21

djw27 opened this issue Aug 10, 2020 · 23 comments

Comments

@djw27
Copy link

djw27 commented Aug 10, 2020

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.

@djw27
Copy link
Author

djw27 commented Sep 9, 2020

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!

@CongeeCafe
Copy link

Yes I can confirm I'm having the same issue too. It would be nice to see it addressed.

@cpannwitz
Copy link

I'm having the same issue, though using a Github repository.

@TylerAHolden
Copy link

Same issue with a private github repo.

@Sly777
Copy link

Sly777 commented Oct 7, 2020

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.

@tysonmatanich
Copy link

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.

@tysonmatanich
Copy link

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.

@marcpicaud
Copy link

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.)

@freshbreweddesign
Copy link

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?

@djw27
Copy link
Author

djw27 commented Dec 18, 2020

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

@devs4522
Copy link

devs4522 commented Jan 7, 2021

@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
Copy link
Author

djw27 commented Jan 12, 2021

@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

@juanpprieto
Copy link

juanpprieto commented Jan 20, 2021

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)

@jasikpark
Copy link

I think I might be having the same problem

@jasikpark
Copy link

Is it dependent on having your github integrated with sentry first??

@jonesphillip
Copy link
Contributor

@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

@jonesphillip
Copy link
Contributor

@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/

@jasikpark
Copy link

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.

lewisjared added a commit to lewisjared/sentry-netlify-build-plugin that referenced this issue May 29, 2021
Allow users to override the respository name passed to the cli.
This is useful for gitlab users where the the repository name is not necessarily the same
as the url (getsentry#21)
vasyl-semilyak-akidolabs pushed a commit to akidolabs/sentry-netlify-build-plugin that referenced this issue Oct 26, 2021
…itory name passed to the cli. This is useful for gitlab users where the the repository name is not necessarily the same as the url (getsentry#21)
leeandher added a commit that referenced this issue Feb 7, 2022
Allow users to override the repository name passed to the cli.
This is useful for gitlab users where the repository name is not necessarily the same
as the URL (#21)
@VitalijusZimaitis
Copy link

VitalijusZimaitis commented Feb 15, 2022

Even though SENTRY_REPOSITORY variable is set on Netlify its still not used when deploying

@alias-mac
Copy link

@VitalijusZimaitis that is because the version wasn't updated in Netlify plugins yet. See my comment here:
#46 (comment)

@kasvith
Copy link

kasvith commented May 16, 2022

For anyone still having this issue

  1. Go to Settings > Repositories
  2. Copy the name on the top (if your repo is gitlab.com/xxx/yyy then Sentry will show like Xxx / Yyy).
  3. Go to Netlify > Build > Environment
  4. Create SENTRY_REPOSITORY and set this value you copied

Enjoy ✨

@saikojosh
Copy link

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.

@muh-hizbe
Copy link

muh-hizbe commented Jan 7, 2023

i have the same issue on private gitlab repo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests