There may be an easier way, but you can load the build.environment and evaluate the 'BUILD_CAUSE_UPSTREAMTRIGGER' environment variables to determine this. The value is boolean. There is also a 'BUILD_CAUSE' environment variable with values of 'MANUALTRIGGER', 'TIMERTRIGGER' and 'UPSTREAMTRIGGER'. There are probably more values, but that is what I see for my jobs.
For a groovy template, this would be:
def env = build.environment
def cause = env.BUILD_CAUSE_UPSTREAMTRIGGER
Assume the same for a script. If you want to find out the user information in the event of a manual trigger, you can install the
Build User Vars plugin.