Fix scheduled task removal

If a build failed to commit_and_push, the scheduled tasks would still be
removed. They are now only removed if and after the commit_and_push
succeeds.