The NLO jet vertex for Mueller-Navelet and forward jets: The gluon part