In one of my plugins I am using the GitSCM instance of a job to analyze the associated Git repository. This works for a lot of cases (input: a Jenkins run):
- For FreeStyle jobs I get the instance from AbstractProject.getSCM()
- For Pipelines jobs I get the instance from the job ((SCMTriggerItem) job).getSCMs()
- For Pipelines jobs with CpsScmFlowDefinition I get the instance from the definition ((CpsScmFlowDefinition) definition).getScm()
But when I use the following pipeline code in an integration test to check out a specific SHA-1 of a repository, then none of these options work to get the SCM. Is in such a case no SCM instance stored in the run or job?
(I get called with a GitSCM instance in a CheckoutListener, thus the instance actually is created)