Refactor method to rebuild images
Code to rebuild a list of selected builds is repeated twice. And they
are slightly different to handle the task ID returned from
build_container.
This patch moves those duplicate code to a single method and ensure to
rebuild images in consisntent behavior.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>