Skip to content
Advertisement

How to run pylint only on changed files in Gitlab?

I’m trying to run pylint only on changed python files, but my build keeps failing. I have extracted the changed files through git diff and saved them in a variable, but when I inject the variable into the pylint call, it fails. It works fine with a hardcoded filename however. Here is my yaml:

JavaScript

Advertisement

Answer

While qathulu answer is adequate, it does not work if no python files are changed. The below prints all the changed files, then use grep to find the changed python files.

Unfortunately there is an error on gitlab, where assigning empty output from grep ends the pipeline. In order to fix that, grep is not assigned to variable until we are sure at least one python file is changed.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement