danger: danger pr [pr] fails but gives no good message how to fix it
Report
What did you do?
$ export DANGER_GITHUB_API_TOKEN=XXXXXXXXXXXX
$ danger pr https://github.com/org/repo/pull/42
Repo is private and token has the right scope for private. Also PR is currently open.
What did you expect to happen?
That it would allow me to test danger locally against a remote PR
What happened instead?
Could not set up API to Code Review site for Danger
For Danger to run on this project, you need to expose a set of following the ENV vars:
- GitHub: DANGER_GITHUB_API_TOKEN
- GitLab: DANGER_GITLAB_API_TOKEN
- BitbucketServer: DANGER_BITBUCKETSERVER_USERNAME, DANGER_BITBUCKETSERVER_PASSWORD, DANGER_BITBUCKETSERVER_HOST
- BitbucketCloud: DANGER_BITBUCKETCLOUD_USERNAME, DANGER_BITBUCKETCLOUD_PASSWORD
Found these keys in your ENV: RBENV_VERSION, DANGER_GITHUB_API_TOKEN, ...
the env var is there and danger even tells me that it saw it but still fails
Your Environment
- Which CI are you running on? My Local machine
- Are you running the latest version of Danger? YES
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 6
- Comments: 16 (6 by maintainers)
Hit the same thing as others above when trying to run locally on macOS & providing a GitHub URL (“bundle exec danger pr <GITHUB_PR_URL>”). Despite echo for the environment variable providing the token, danger believes it isn’t there, but then lists the environment keys which includes the key it claims is missing.
Running with verbose on, I saw an exception due to a plugin have a conflicting gem version & uninstalled the conflicting version via gem uninstall, but that just led to the same issue still but now without any sort of exception or clue of what to do next.
So now I just get this:
An interesting thing to note is Danger is obviously picking up the value as when I changed out the token with a brand new, never used token from GitHub, GitHub reports it attempting to access as it changes from “Never used” to “Used within the last week” after running the command.
Running an
echo $DANGER_GITHUB_API_TOKENdoes spit out the token so unless ruby is using a weird set of environment vars it should be able to see it. It even says in the error message that it sees theDANGER_GITHUB_API_TOKENin the list of available environment vars…🤔I am also getting this error when trying to connect to my GitHub enterprise instance.
My environment variable ‘DANGER_GITHUB_HOST’ is a custom URL to my GitHub enterprise server (xxxghub.xxx.com). It looks like this piece of code is inferring which source code repository you’re using by using a regular expression to match on the string ‘github’, -which I don’t have-.
def get_repo_source(repo_url) if repo_url =~ /github/i RequestSources::GitHub elsif repo_url =~ /gitlab/i RequestSources::GitLab elsif repo_url =~ /bitbucket\.(org|com)/i RequestSources::BitbucketCloud end endStill without any luck: