[JENKINS-64406] Expand environment variables when performing lightweight-checkout
JENKINS-64406 - Expand environment variable to perform lightweight-checkout for Pipeline script from SCM using single branch
When performing a lightweight-checkout for Pipeline script from SCM using a global environment variable with a single branch, would lead to an error as the environment variable support was not provided in the supports(SCM source) method of GitSCMFileSystem class. This PR focuses on providing environment variable support for a single branch build only. For multiple branches a full-checkout is performed and seems more rational for now.
Checklist
- [x] I have read the CONTRIBUTING doc
- [x] I have referenced the Jira issue related to my changes in one or more commit messages
- [x] I have added tests that verify my changes
- [x] Unit tests pass locally with my changes
- [ ] I have added documentation as necessary
- [x] No Javadoc warnings were introduced with my changes
- [x] No spotbugs warnings were introduced with my changes
- [ ] Documentation in README has been updated as necessary
- [ ] Online help has been added and reviewed for any new or modified fields
- [x] I have interactively tested my changes
- [x] Any dependent changes have been merged and published in upstream modules (like git-client-plugin)
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
Further comments
Although the environment variable support could also be provided in build(Item owner, SCM scm, jenkins.scm.api.SCMRevision rev) method as well but then the branch name has to be checked against the issue JENKINS-57587 again and other match cases, defeating the purpose of supports (SCM source) method.