The JENKINS_URL env var when pipeline docker agents are used appears to be missing. HUDSON_URL is defined.