[FIX JENKINS-23007] Consider environment when polling.

Otherwise, the credentials for locations with variables in their URL
aren't considered, requiring a fallback to Additional Credentials.