Overview
In any settings file, you can add conditional settings using theConditionalSettings property. When conditions are met, the specified settings are applied on top of the base settings.
Basic Structure
Conditional settings are defined as an array of objects, each containing:- Conditions - One or more condition types (branches, workflows, buildModes, etc.)
- Settings - The settings to apply when all conditions are met
Condition Types
Conditional settings can be applied based on the following conditions:Settings applied to repositories matching the patterns.Example:
Settings applied to projects matching the patterns.Example:
Settings applied when building with these build modes.Example:
Settings applied to branches matching the patterns.Example:
Settings applied to workflows matching the patterns.Example:
Workflow names are sanitized before matching. Sanitization removes invalid filename characters like leading spaces, quotes, colons, slashes, and special characters. For example,
" CI/CD" becomes "CICD".Settings applied for users matching the patterns.Example:
Common Use Cases
Feature Branch Configuration
Disable signing and publishing for feature branches to speed up development:Build Mode Preprocessor Symbols
Define different preprocessor symbols for different build modes:Workflow-Specific Settings
Apply different failure thresholds for different workflows:Environment-Specific Configuration
Different settings for different deployment branches:Multi-Country Testing
Test additional countries only in specific workflows:Multiple Conditions
You can specify multiple conditions in a single conditional settings block. All conditions must be met for the settings to apply:- The branch matches
release/*AND - The build mode is
Clean
Organizational Conditional Settings
Conditional settings can be defined at the organizational level inALGoOrgSettings:
bcsamples-* in the organization won’t sign apps on branches matching features/*.
Settings Application Order
All conditional settings that have their conditions met are applied in the order of settings file + appearance.
Example of Application Order
main branch with Clean build mode:
- Base:
country: us,enableCodeCop: false - First conditional (branch=main):
enableCodeCop: true,failOn: warning - Second conditional (branch=main, buildMode=Clean):
enableUICop: true,failOn: error
country: us, enableCodeCop: true, enableUICop: true, failOn: error
Workflow Default Inputs in Conditional Settings
You can useworkflowDefaultInputs within conditional settings to apply workflow input defaults only when certain conditions are met:
When multiple conditional settings blocks match and both define
workflowDefaultInputs, the arrays are merged (all entries are kept). When defaults are applied to workflows, the last matching entry for each input name wins.Pattern Matching
All condition arrays support wildcard patterns:*- Matches zero or more characters?- Matches exactly one character
feature/*- Matches all branches starting withfeature/*-test- Matches anything ending with-testv?.?- Matchesv1.0,v2.3, etc.*- Matches everything
Workflow Name Sanitization
When matching workflow names for conditional settings, AL-Go sanitizes the actual workflow name before comparison:- Leading spaces removed
- Quotes removed
- Colons removed
- Slashes removed
- Other special characters removed
" CI/CD"→"CICD""Pull Request: Build"→"Pull Request Build"
Best Practices
Keep conditions simple
Keep conditions simple
Use the minimum number of conditions needed. Complex multi-condition blocks can be hard to debug.
Document your conditionals
Document your conditionals
Add comments in your JSON (if supported by your editor) or maintain separate documentation explaining why conditional settings exist.
Test thoroughly
Test thoroughly
When adding conditional settings, test that they apply correctly by running workflows under the expected conditions.
Use specific patterns
Use specific patterns
Prefer specific patterns like
feature/new-ui over broad patterns like * to avoid unintended matches.Order matters
Order matters
Remember that conditional settings are applied in order. Place more specific conditions after general ones if you want them to override.
Leverage organizational settings
Leverage organizational settings
Use organizational conditional settings for policies that should apply across all repositories.
Debugging Conditional Settings
To debug which settings are applied:- Check workflow logs for the “Read settings” step
- Settings are logged showing the final merged result
- Use different settings values to trace which conditionals are applied
- Test with specific branches/workflows to verify conditions match
Related Topics
- Settings Overview - Understand the settings hierarchy
- Basic Project Settings - Settings that can be applied conditionally
- Advanced Settings - More settings for conditional application