Megalinter apply fixes for Gitlab #3448
Replies: 2 comments 1 reply
-
@MouadRabihi07 it has indeed never been implemented on default gitlab-ci.yml workflow If you succeed to do it, would you like to make a PR on https://github.com/oxsecurity/megalinter/blob/main/mega-linter-runner/generators/mega-linter/templates/.gitlab-ci.yml ? If it can help, it could be something like the following (requiring to create an access token and define it in an env variable) , that I used on sfdx-hardis monitoring script |
Beta Was this translation helpful? Give feedback.
-
Hi, I tried the same thing on GitLab CI agent running in k8s cluster. My megalinter:
# ... tags, image, stage... you know
script:
# I have pasted these commands for sure:
- git config --global user.name "${GITLAB_USER_NAME}"
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git fetch origin
- git checkout -B "${CI_COMMIT_REF_NAME}" origin/"${CI_COMMIT_REF_NAME}"
- git pull origin "${CI_COMMIT_REF_NAME}"
- git branch --set-upstream-to=origin/"${CI_COMMIT_REF_NAME}" "${CI_COMMIT_REF_NAME}"
- git remote set-url origin https://${GITLAB_ACCESS_TOKEN_MEGALINTER}@gitlab.domain/${CI_PROJECT_PATH}.git
# then run megalinter:
- bash /entrypoint.sh
variables:
DEFAULT_WORKSPACE: $CI_PROJECT_DIR
LOG_LEVEL: INFO
PARALLEL_PROCESS_NUMBER: 6
SHOW_ELAPSED_TIME: 'true'
PRINT_ALIGNED: 'true'
LINTER_RULES_PATH: .linters
SHOW_FLAVORS_INFO: 'false'
GITLAB_COMMENT_REPORTER: 'true'
VALIDATE_ALL_CODEBASE: 'true'
APPLY_FIXES: all
APPLY_FIXES_EVENT: none
APPLY_FIXES_MODE: pull_request
DEFAULT_BRANCH: $CI_COMMIT_REF_NAME
GIT_SOURCE_BRANCH: $CI_COMMIT_REF_NAME
FORMATTERS_DISABLE_ERRORS: true
CONSOLE_REPORTER: 'true'
CONSOLE_REPORTER_SECTIONS: 'true'
PROCESS_ON_GIT_DIFF: 'false'
OUTPUT_ARTIFACTS_URL: 'true'
GITLAB_ACCESS_TOKEN_MEGALINTER: # ... my token with API and repository r/w permissions But I got: I also pasted debug commands before ML run:
Looks good, but ML still can't find the "original branch". How it works? Can you send me a URL to the code where this "source branch" detects? Or I need to do it manually like in this issue? I would like to to it a native way with a merge request rather than using postscript commands. |
Beta Was this translation helpful? Give feedback.
-
Hello, i'm using megalinter in a Gitlab ci pipeline, and i was wondering if the option to auto apply fixes with a commit created by megalinter is only possible in github workflows, or i can implement this also in my pipeline ?
Beta Was this translation helpful? Give feedback.
All reactions