[jenkins] - fixed approach for detecting the current branch once and for all (works for attached and detached heads and also for pull requests)