Oil posted a strong weekly gain as Middle East conflict and mounting supply risks kept markets on edge.