danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.04k stars 136 forks source link

Error "Only absolute URLs are supported" on Bitrise CI + Bitbucket #500

Closed metpb closed 2 years ago

metpb commented 2 years ago

Hi, I created a workflow for danger on Bitrise using a PR trigger via Bitbucket, but getting an error (refer screenshot) when running any of both danger-swift ci and danger-swift pr {PR link}. The setup is for an iOS project that has a Dangerfile.swift in its root directory.

Please don't mind me but I have a few questions that I want to ask here (since I couldn't find answers elsewhere):

  1. does danger-swift support Bitbucket PRs yet?
  2. what's the difference between danger-swift pr and danger-swift ci?
  3. how does danger-swift know the PR ids, PR url, etc in Bitrise CI?

I have a few more questions, but just want to get unstuck from this problem first. And I would really appreciate it if you could share any link to such a doc that might help me to better understand what's causing this. Thanks in advance!

Screenshot 2022-01-20 at 12 00 31 AM

bobergj commented 2 years ago

how does danger-swift know the PR ids, PR url, etc in Bitrise CI?

You can see the environment variables danger-js (which danger-swift invokes) expects from bitrise here: https://github.com/danger/danger-js/blob/main/source/ci_source/providers/Bitrise.ts

f-meloni commented 2 years ago

does danger-swift support Bitbucket PRs yet?

Yes, as @bobergj pointed out it does.

what's the difference between danger-swift pr and danger-swift ci?

danger-swift pr is to locally test a Dangerfile against a PR, while danger-swift ci is the one you use on CI to run danger, which gets the PR link from your CI and posts back the result on the PR.

how does danger-swift know the PR ids, PR url, etc in Bitrise CI?

Those are taken by Bitrise, you can see how in the link posted in the previous comment.

For the issue you show 🤔 I don't 100% remember how Bitrise works in detail, but might it be that your current job trigger is not one that is pull request related? e.g., push instead of pull_request?

metpb commented 2 years ago

@bobergj @f-meloni Thanks, both! The integration is working now. Appreciate the help!

Mistake summary: I had the wrong env var setup. I had added the DANGER_BITBUCKETSERVER_HOST=bitbucket.org env var (along with the other required vars) which meant that getPlatformForEnv was picking up BitBucketServer platform instead of BitBucketCloud resulting in various other issues down the pipeline.

Another issue was related to account permission on Bitbucket, which was easy to resolve.

Sharing my log for context

+ DEBUG='*'
+ danger-swift ci --verbose
2022-01-25T12:22:53.857Z danger:process_runner Debug mode on for Danger v10.1.0
2022-01-25T12:22:53.859Z danger:process_runner Starting sub-process run
2022-01-25T12:22:53.863Z danger:BitBucketServerAPI GET bitbucket.org/rest/api/1.0/{BITRISEIO_GIT_REPOSITORY_OWNER}/{BITRISEIO_GIT_REPOSITORY_SLUG}/pull-requests/4397/changes?start=0
Only absolute URLs are supported
Retry 1 of 3.
Only absolute URLs are supported
Retry 2 of 3.
Only absolute URLs are supported
Retry 3 of 3.
Error:  TypeError: Only absolute URLs are supported