danger-js icon indicating copy to clipboard operation
danger-js copied to clipboard

Codeship CI_REPO_NAME not accurate

Open TSMMark opened this issue 6 years ago • 4 comments

https://github.com/danger/danger-js/blob/48ab882843f30f9fee8a9cbf48155307f5609f52/source/ci_source/providers/Codeship.ts#L68

The CI_REPO_NAME env var only contains the project name and not the user / organization. We are using Codeship Pro. Not sure if Basic has different results. This causes the API requests such as https://api.github.com/repos/REPO_NAME_HERE/pulls to fail with 404 status. Example:

Request failed [404]: https://api.github.com/repos/gourami/pulls
Response: {
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3/repos/#get"
}

We tried doing a printenv and could not find a Codeship env var which contained the complete name e.g. Organization/Repository, so I'm not sure how to globally fix this.

We are resorting to overriding the CI_REPO_NAME env var inline when calling danger script.

TSMMark avatar Nov 07 '19 21:11 TSMMark

Thanks will keep this open, might be worth raising an issue with them about making something available

orta avatar Nov 07 '19 21:11 orta

I opened a support ticket with Codeship and will report back here upon response.

TSMMark avatar Nov 11 '19 16:11 TSMMark

Hey Mark, Thanks for your feature request for CodeShip!I have shared this request for enhancement with our product team as a formal request so they are aware of this as well. As a note, we cannot currently offer any timeline guarantees for requests for features to be included in CodeShip.In the meantime since this isn't currently available I would recommend just running a command to try and retrieve the information you are looking for from the configured GitHub repo in your app.Please let us know if you have any other questions. Best regards

Sounds like we'll be hardcoding CI_REPO_NAME in the meantime

TSMMark avatar Nov 12 '19 14:11 TSMMark

Hey Mark, Product has decided that this will be in the backlog for now so I would recommend sticking with a work around. Also you can follow along at: https://changelog.codeship.com for any changes to our system. Best regards

RIP

If this helps anyone, I was able to write this command which works for me locally at least. Haven't tried it from within a Codeship Pro docker container yet tho — Idk if the git config would be different in there.

▶ git config --get remote.origin.url
# => https://github.com/Vydia/gourami.git

▶ git config --get remote.origin.url | sed 's/.*\/\([^ ]*\/[^.]*\).*/\1/' # Capture last 2 path segments before the dot in .git
# => Vydia/gourami

This is the desired result as Vydia is the organization name and gourami is the package name. Combined they can help form the complete CI_REPO_NAME

TSMMark avatar Nov 13 '19 18:11 TSMMark