[BUG] danger ci not running in a gitlab.com MR
See original GitHub issueDescribe the bug Danger doesn’t think it’s running in a CI environment or a PR context in a gitlab.com MR (I can’t quite tell which, DEBUG logging is a little sparse on startup).
Skipping Danger due to this run not executing on a PR.
To Reproduce Steps to reproduce the behavior:
- I added a simple Dangerfile
import { message, danger } from "danger"
const modifiedMD = danger.git.modified_files.join("- ")
message("Changed Files in this PR: \n - " + modifiedMD)
- And a basic .gitlab-ci.yml
danger:
image: node:lts
before_script:
- printenv
script:
- DEBUG="*" npx danger ci
- To a branch and opened an MR
- Check the pipeline logs (snipped some of the env output)
$ printenv
...
GITLAB_CI=true
CI=true
DANGER_GITLAB_API_TOKEN=[MASKED]
...
$ DEBUG="*" npx danger ci
2020-04-02T15:34:30.576Z danger:process_runner Debug mode on for Danger v10.0.0
2020-04-02T15:34:30.578Z danger:process_runner Starting sub-process run
Skipping Danger due to this run not executing on a PR.
Expected behavior
I hoped that the presence of the CI and GITLAB_CI and other env vars would inform danger that it was running in a GitLab CI environment!
Screenshots If applicable, add screenshots to help explain your problem.
Your Environment
software | version |
---|---|
danger.js | 10.0.0 |
node | 12.6.1 |
npm | 6.13.4 |
Operating System |
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Troubleshooting CI/CD - GitLab Docs
If a pipeline does not seem to run at all, with no error message, it may also be due to rules or only/except...
Read more >Danger bot - GitLab Docs
Danger bot. The GitLab CI/CD pipeline includes a danger-review job that uses Danger to perform a variety of automated checks on the code...
Read more >Think of a way to run Danger checks against MR from forks
Think of a way to run Danger checks against MR from forks ... Generating of merge request (diff) comments based on output of...
Read more >Danger failed: Invalid `Dangerfile` file (#227814) - GitLab.org
Danger failing occasionally when run in community MR. #343300. Hint author to rebase when Danger cannot find the right commit. #352152.
Read more >Merge request pipelines - GitLab Docs
This error can happen when you select Run pipeline in a merge request, but the project does not have merge request pipelines enabled...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, the gitlab documentation for the CI_MERGE_REQUEST_IID variable says
https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
That means I need to add this to my .gitlab-ci.yml
I could send a PR with updated GitLab docs if you like?
I usually don’t have my ci run on merge requests but on branch commits, attached to merge requests, so I never have
CI_MERGE_REQUEST_IID
. On the other hand, there is aCI_OPEN_MERGE_REQUESTS
that containsproject/path!id
.I ended up having: