-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
PRE_COMMANDS environment variable syntax #1605
Comments
I also struggled with this, and we would gladly accept a pull request to improve the pertinent documentation. This is the syntax we have been using in our MegaLinter config files: *_PRE_COMMANDS:
- command: echo hello world I have never even tried setting this via an environment variable, but if someone gets that working, I would be curious to learn how they did it. |
We use get_list method to get PRE_COMMANDS value I'll try to check if I can have a different behaviour if the string starts with |
This is what I do as well but because I'm trying to workaround some git shenanigans in a repository, I also have to inject an environment variable. PRE_COMMANDS: #$REPO_TOKEN is injected in the megaLinter workflow
- command: git config --global url."https://oauth2:[email protected]".insteadOf ssh://[email protected] |
You could use |
* [automation] Auto-update linters version, help and documentation * [MegaLinter] Apply linters fixes * Fix build issues * Build doc * [automation] Auto-update linters version, help and documentation * [MegaLinter] Apply linters fixes * [MegaLinter] Apply linters fixes * Fix SARIF count * Disable trivy in PR DEV job (now secured by Ox) * DevSkim: Ignore megalinter-reports Fixes #1603 * Fix build.py for DOCKERFILE_DOCKERFILELINT * Fix SARIF * Fix SARIF reading * Fix SARIF test method * Fix counting sarif errors * [MegaLinter] Apply linters fixes * elif quick build * Load JSON when list obj objects in env vars #1605 * changelog quick build * Update secretlint test cases * [MegaLinter] Apply linters fixes * AutoFix pre_commands using npm install Fixes #1258 * Fix SARIF test class again * Also get errors number from SARIF invocations * Fix againnnn * Fix test cases * Linter fixes Co-authored-by: nvuillam <[email protected]>
@nvuillam oh wow, super fast turn around, just tried this with 6.0.4, and it works great! my syntax (for Github Actions) was as follows env:
PRE_COMMANDS: >-
[{"cwd": "workspace", "command": "git config --global url.\"https://oauth2:${{ secrets. REPO_TOKEN }}@github.com\".insteadOf ssh://[email protected]"}] |
@timothysparg > I'm glad it works :) You can star the repo if you like 😇 |
Hi There! |
@johnkk84 I don't know this syntax, but you can define multiple commands in your .mega-linter.yml file :) Examples on https://megalinter.io/latest/config-precommands/#pre-commands |
Thanks first of all I Need to fix issue with my config cause after Global configuration local config yaml wont work:(. Will let you konow also about json when will find solution since is a list so elements should be delimiter by ",". |
I've fixed my gitlab pipeline. I used include pipelines from another project and faced issue with variables scope/permission. I've added variable into my lib pipeline repo then it works: MEGALINTER_CONFIG: .mega-lister.yml
|
@johnkk84 thanks for the precision :) |
It appears that you should be able to set PRE_COMMANDS as an environment variable, but I can't seem to get the syntax worked out, could somebody enlighten me as to how it should look?
It would appear that you need to pass it in as some kind of structured format, as I get the following stacktrace when I try use a normal string:
My latest attempts where to try and use a JSON syntax, but this doesn't seem to be the correct approach either
[{"cwd": "workspace", "command:": "echo \"hello world\""}]
The text was updated successfully, but these errors were encountered: