[JENKINS-25559] - A direct unit test for the issue

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
[FIXED JENKINS-25559] - Substitute variables using build substitution macros

The change reworks https://github.com/jenkinsci/perforce-plugin/pull/60 from @stuartrowe
The initial fix caused the loss of "basename" variable in the substitution

Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>