No rules are being processed #1426
-
Hi, I have already checked out the #1332, but unfortunately keep running into a wall with getting this to work. I have set up a .ps-rule folder within my repository, which contains the files bicep.Rule.ps1: I have also set up a templates folder, which contains a main.bicep file: I have set up the ps-rule.yaml file in the root: I then have a pipeline which installs the dependencies and runs the Assert-PSRule: Unfortunately it seems like it is unable to find my custom rule, given that it processes 0 rules: I assume I am missing something somewhere, but I have unfortunately gotten to a point where I don't know where to look anymore. I have attempted using the example in the documentation (https://microsoft.github.io/PSRule/v2/scenarios/validation-pipeline/validation-pipeline/#complete-example), but it only works when the folder to analyze is the .ps-rule. This seems like an awesome extension and I would really like to get it working. Any idea where I am going wrong? :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@Crowiiie Thanks for the question. Three things to try that should resolve this. Use PSRule for AzureAzures resources from a Bicep file are a little tricky because they need to be expanded (to resolve parameters, variables, functions, and modules). We've already done a lot of the work through PSRule for Azure. Have a look here Installation and Creating your pipeline. The If you do not want to use the Azure Pipeline task installable from the Visual Studio Marketplace suggested by these docs, which is the simplest path, then:
Update the type for the custom ruleInstead of using Configure type bindings for local rulesSet the For example: # Configure binding options
binding:
targetType:
- 'resourceType'
- 'type' I hope that helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you for taking the time to write out such a comprehensive answer! I have implemented the changes suggested above, and now both the Azure Pipeline task and the Powershell script options are working properly. 👍 |
Beta Was this translation helpful? Give feedback.
@Crowiiie Thanks for the question. Three things to try that should resolve this.
Use PSRule for Azure
Azures resources from a Bicep file are a little tricky because they need to be expanded (to resolve parameters, variables, functions, and modules). We've already done a lot of the work through PSRule for Azure. Have a look here Installation and Creating your pipeline. The
AZURE_BICEP_FILE_EXPANSION
configuration option in yourps-rule.yaml
is for PSRule for Azure, and won't work if it is not installed.If you do not want to use the Azure Pipeline task installable from the Visual Studio Marketplace suggested by these docs, which is the simplest path, then:
…