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
Need a way to configure exit codes #1586
Comments
Thought about the exit codes quite a bit. I'd love for informational level rules to be displayed in the output without affecting the exit code, potentially even as the default behavior
echo $? % 4 | bc # exit code modulo 4 should filter warnings and informational
echo $? % 8 | bc # exit code modulo 8 should filter informational Can also generally workaround with infracost/infracost#1478 (comment) @andrew-glenn if you don't care about even seeing the warning and informational violations, simply |
In AWS-Native services (ala CodeBuild, and CodePIpeline that leverages CodeBuild), the shell environment is by-default configured to exit on non-zero status codes. There are things that can be done to mitigate cfn-lint's behavior, such as The current behavior puts me in a position where I can't trust the binary notion that non-zero == failure, and instead need to inspect the exit codes (via source-code, subject to change) to determine the path forward. At minimum (5pm Friday, before Vacation minimum), I'd expect to see this documented in --help and the README. |
@PatMyron - the documentation seems to indicate that's possible. I'm not finding that to be the case, however.
Nor does this...
|
might just be the option order? think try one of these:
|
Closing the gap - both of those suggestions work. There's another issue open to document the exit codes. closing. |
I think the only trick here is if someone wants to see the messages but change the exit code. I'm glad the |
as @kddejong this is exactly the use case. Legacy code base that we're fixing gradually. I want to be able to see the warning so that I can go and fix them bit by bit, but I don't want it to exit with non-zero so that it breaks Jenkins. Just the way ESLint, for example, works |
Another way to write @PatMyron's example cfn-lint --include-checks I -- template.yaml || (($? % 4 ? 0 : 1)) if exit code is |
Given the amount of issues related to this I believe bringing some of the workaround mechanisms into the cfn-lint code base make sense. |
created #2436 to help move this logic into cfn-lint |
@kddejong #2346 is not related to this error. Is a fix for this actively being worked on? I've seen a number of reported issues that I am also having where github actions treats warnings from cfn-lint as an error and fails since version v0.66.0. The only viable workaround is to disable warnings or the specific warning you have trouble with, which defeats the purpose of warnings. Suppressing warnings is not a fix to this problem. |
Wrong #. Updated now. The workarounds above will work for you and release v0.90.0 has a new way to configure exit codes. You can look at #2460 to see the readme updates on how to use it. |
https://github.com/aws-cloudformation/cfn-python-lint/blob/0ad76abe7dbd33dc404cd1cedd85c9643822d347/src/cfnlint/core.py#L55-L66
I'm not finding a way to non-zero exit on Errors only. Currently, based on the logic above, an informational message will trigger a non-zero exit code (8). Working around this in CICD pipelines is frustrating. A way to say
--non-zero-exit-code ERROR
would be splendid.The text was updated successfully, but these errors were encountered: