feat: add conditional execution for tasks and commands by vmaerten · Pull Request #2564 · go-task/task
changed the title
feat(if): add conditional execution for tasks and commands
feat: add conditional execution for tasks and commands
vmaerten
marked this pull request as ready for review
Add `if` field to tasks and commands that allows conditional execution based on a shell command exit code. When the condition returns non-zero, the task/command is silently skipped (with verbose logging). - Task-level: skip entire task if condition fails - Command-level: skip individual command if condition fails - Supports template variables in conditions - Works with for loops (condition evaluated per iteration) - Works with deferred commands
Add comprehensive test cases for: - Task calls in cmds with if conditions - Go template functions (eq, ne, and, or) - Direct template variable evaluation - CLI variable overrides - Task-level if with templates
Add comprehensive golden fixture tests for if feature: - Command-level if (true/false) - Task-level if (true/false) - Task calls with if conditions - Go template functions (eq, ne, and, or) - Direct template variable evaluation - CLI variable overrides - For loops with if conditions
This was referenced
Jan 21, 2026Copilot AI pushed a commit to libor-m/task that referenced this pull request
Mar 27, 2026Copilot AI pushed a commit to libor-m/task that referenced this pull request
Mar 27, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters