You can use Condition Tasks to put logic into your build, which helps avoid a rapid increase of plans or wrapping everything with script tasks.
If the condition evaluates to true, the tasks following it in the job are executed. If the condition evaluates to false, they are skipped.
By default, all tasks from the Condition Task to the end of the job are in scope for being skipped. However, you can configure the Condition Task to only execute or skip the next task or any number of subsequent tasks.
A user with global administration permissions can write Condition Tasks using a groovy script. Due to security considerations, non-admins cannot. Non-admins can, however, configure the number of tasks to be skipped and change the order of the configurable tasks.
To access these tasks, create a build plan, and add a stage and job. From there, click Add Task, and then ScriptRunner Condition Tasks.
Order of Execution
All these Condition Tasks are executed when the job is queued. Even if there are previous tasks in the job, the Condition Tasks are evaluated first to determine which of the tasks in the job should execute. This is true even if your Condition Task occurs late in the job.