'How to enable linting in r package in gitlab ci/cd pipeline
I have created CI pipeline in gitlab for r-package. I need to capture the lint output and fails the job if there is any lint error. I'm unable to read the output of lintr command.
image: r-base:4.1.2
stages:
- LintR
LintR:
stage: LintR
script:
- cd ..
- R -e "capture.output(lintr::lint_package(\"./test-r/\"), file=\"./lint_output.txt\")"
- cd isp-r && mv ../lint_output.txt .
artifacts:
paths:
- ./lint_output.txt
when: always
How to capture the output in gitlab CI/CD
Solution 1:[1]
Try the following:
image: r-base:4.1.2
stages:
- LintR
LintR:
stage: LintR
script:
# redirect lintr stdout and stderr to file
- CI="" R -e "lintr::lint_package()" &> lint_output.txt
# fail if file is not empty
- [ ! -s lint_output.txt ]
artifacts:
paths:
- lint_output.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Richard |
