microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
384 stars 247 forks source link

Run-AlPipeline with CodeCops: unable to apply custom ruleset #1480

Closed FabioC34 closed 3 years ago

FabioC34 commented 3 years ago

Hi Freddy, I tried to enable CodeCop, PerTenantExtensionCop, etc… but I didn’t find a parameter where pass the file “app.ruleset.json” to modify or bypass the logic of some checks. The app.ruleset.json file is in the repository and in settings.json there is the “al.ruleSetPath” parameter correctly set. Of course compiling the app in VSCode works correctly

Thank you

Scripts used Set artifact = /OnPrem/17.1.18256.18792/it Set pipelineName = Fabio-ci Set containerName = srvbcdev19-fabio-ci Set installApps = '' Set previousApps = '' Set appSourceCopMandatoryAffixes = '' Set appSourceCopSupportedCountries = '' Set appFolders = '/' Set testFolders = '' Set memoryLimit = '6G' Set additionalCountries = '' Set genericImageName = '' Set vaultNameForLocal = 'BuildVariables' Set bcContainerHelperVersion = 'preview' Set installTestFramework = False Set installTestLibraries = False Set installPerformanceToolkit = False Set enableCodeCop = False Set enableAppSourceCop = False Set enablePerTenantExtensionCop = True Set enableUICop = True Set doNotSignApps = True Set doNotRunTests = True Set cacheImage = True Set CreateRuntimePackages = True BcContainerHelper version 1.0.15-preview270

freddydk commented 3 years ago

At this time, you can do this by overriding CompileAppInBcContainer method:

# either set $rulesetfile here
Run-alpipeline `
    -parameter `
    -CompileAppInBcContainer { 
        Param([Hashtable]$parameters)
        # or set $rulsetfile here
        Compile-AppInBcContainer @parameters -rulesetfile $rulesetfile
    }

I might create a way to set a ruleset file in settings to avoid overrides.

FabioC34 commented 3 years ago

Ok, perfect Freddy And thanks a lot for the current workaround!!!

freddydk commented 3 years ago

In 1.0.15 and later you now have a RuleSetFile parameter on Run-AlPipeline. The RuleSetFile should be relative to the basefolder. Run-AlPipeline also have a parameter called useDefaultAppSourceRuleSet which will use the default AppSourceCop ruleset for AppSource Validation. Both parameters can be used at the same time.