Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Expose --id to rules #1279

Open
glensc opened this issue May 10, 2022 · 6 comments
Open

Feature: Expose --id to rules #1279

glensc opened this issue May 10, 2022 · 6 comments
Labels

Comments

@glensc
Copy link
Contributor

glensc commented May 10, 2022

I want to get the value of danger ci --id to use in rules.

The intent is to run danger twice on CI pipeline, first time early to report coding errors, second time late to grab any artifacts from CI jobs and format them as comments.

The property itself is here:

@glensc glensc added bug feature and removed bug labels May 10, 2022
@glensc
Copy link
Contributor Author

glensc commented May 10, 2022

for now i'll use environment variable in my rules:

export const DANGER_ID = process.env.DANGER_ID || 'Danger';

but that's just duplicating the same thing, I need to set the env and need to pass --id arg when executing danger second time on the pipeline

@glensc
Copy link
Contributor Author

glensc commented May 10, 2022

Ideas, guides? on how to implement this?

@fbartho
Copy link
Member

fbartho commented May 10, 2022

We run two different Dangerfiles in our repo, so we don't need access to the ID within a single Dangerfile. Is that technique worthwhile for you @glensc?

danger ci --id "$1" --dangerfile "$DANGER_FILES_DIR/$1.ts" where $1 is the name of the file we're executing.

This then lets us easily trigger different danger files from different events or steps in a Github Actions Workflow, and not have them trip over each other.

@orta
Copy link
Member

orta commented May 11, 2022

Feels like a field which could be available in the main danger export to me

@glensc
Copy link
Contributor Author

glensc commented May 11, 2022

@orta, so something here:

  • return {
    git,
    // Strictly speaking, this is a lie. Only one of these will _ever_ exist, but
    // otherwise everyone would need to have a check for GitHub/BBS in every Dangerfile
    // which just doesn't feel right.
    github: github!,
    bitbucket_server: bitbucket_server!,
    bitbucket_cloud: bitbucket_cloud!,
    gitlab: gitlab!,
    utils: {
    sentence,
    href,
    },
    }

just add root level dangerId there? or as some structure? or under utils?

@orta
Copy link
Member

orta commented May 11, 2022

I think dangerID in there would be 👍🏻 (utils is for functions IMO)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants