Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] danger ci not running in a MR

See original GitHub issue

Describe the bug Danger doesn’t think it’s running in a CI environment or a PR context in a 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:

  1. 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)
  1. And a basic .gitlab-ci.yml
    image: node:lts
        - printenv
        - DEBUG="*" npx danger ci
  1. To a branch and opened an MR
  2. Check the pipeline logs (snipped some of the env output)
$ printenv
 $ 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:open
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

AnthonyMastreancommented, Apr 2, 2020

Oh, the gitlab documentation for the CI_MERGE_REQUEST_IID variable says

The IID of the merge request if the pipelines are for merge requests. Available only if only: [merge_requests] or rules syntax is used and the merge request is created.

That means I need to add this to my .gitlab-ci.yml

  - merge_requests

I could send a PR with updated GitLab docs if you like?

mat813commented, Dec 21, 2021

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 a CI_OPEN_MERGE_REQUESTS that contains project/path!id.

I ended up having:

    - yarn danger ci --failOnErrors
Read more comments on GitHub >

github_iconTop 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) -
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found