How to differentiate jenkins job between scm trigger and manual trigger

Hi All,

I have configured jenkins to run a testng automation script which is run in a remote server ( jenkins node agent ) , Jenkins works as a CI/CD Server which will fetch the script from git and execute it in windows remote server and perform the browser executions.

I have been asked to configure jenkins to fetch the code when changes are made using poll scm and when manually or triggered by scheduler, it needs to run the saved script in the jobs workspace.

How to configure a jenkins freestyle/maven job to build the code from Git when code changes are made in Git and when manually triggered or triggered by an upstream job, needs to fetch the previously run code saved in the workspace:**

My senior person told me that this can reduce the overall time the script completes since the code is fetched from the local workspace and run…
Can anyone provide suggestions for the above testcase?