[JENKINS-16412] Don't use local name if flatten is true

Only use the local name if it has been used for checkout