danger / danger-js

⚠️ Stop saying "you forgot to …" in code review
http://danger.systems/js/
MIT License
5.29k stars 368 forks source link

[BUG] Cannot run in bitbucket without access to bitbucket cloud #1460

Closed yq314 closed 3 months ago

yq314 commented 4 months ago

Describe the bug I'd like to run dangerjs in bitbucket cloud and I don't need access to any cloud features, I just need to validate git changed rules so accessing bitbucket API is not necessary.

I've tried with --no-publish-check and --text-only, however when I run it in ci it still require DANGER_BITBUCKET_USERNAME and DANGER_BITBUCKET_PASSWORD. Is there a way to skip this setup completely?

To Reproduce Steps to reproduce the behavior:

  1. danger ci --no-publish-check --text-only --dangerfile=dangerfile.js

Expected behavior

It should run successfully if I don't need anything from the API, like danger.bitbucket_cloud. I'm only using danger.git.modified_files in the dangerfile.

Screenshots If applicable, add screenshots to help explain your problem.

The DANGER_GITHUB_API_TOKEN/DANGER_BITBUCKETSERVER_HOST/DANGER_GITLAB_API_TOKEN environmental variable is missing
Without an api token, danger will be unable to comment on a PR
Error:  Error: Cannot use authenticated API requests.
    at getPlatformForEnv (/usr/local/lib/node_modules/danger/distribution/platforms/platform.js:96:11)
    at /usr/local/lib/node_modules/danger/distribution/commands/ci/runner.js:88:79
    at step (/usr/local/lib/node_modules/danger/distribution/commands/ci/runner.js:33:23)
    at Object.next (/usr/local/lib/node_modules/danger/distribution/commands/ci/runner.js:14:53)
    at fulfilled (/usr/local/lib/node_modules/danger/distribution/commands/ci/runner.js:5:58)

Your Environment

software version
danger.js
node
npm
Operating System

Additional context Add any other context about the problem here.

alessandro308 commented 3 months ago

Did you try to pass random variables? If you dont need them, you can pass any variables since they should remain unused

yq314 commented 3 months ago

Did you try to pass random variables? If you dont need them, you can pass any variables since they should remain unused

yeah but looks like it will always make calls to bitbucket api for diff and commits.

fbartho commented 3 months ago

You can run danger-js in "offline mode" using the FAKE_CI (search docs/repo) and unset the related bitbucket environment flags.

(In other words: Don't tell danger-js that it's in bitbucket if you want to skip calling the bitbucket API)

yq314 commented 3 months ago

Thanks, FAKE_CI works, but I ended up running danger local as danger ci doesn’t allow me to specify base branch

fbartho commented 3 months ago

@yq314 danger local is perfectly fine and I probably should have recommended that one before recommending FAKE_CI! Cheers!