This can be done using the Jenkins Build User Vars Plugin
, which provides a set of environment variables, including the user who started the build. It provides environment variables such as BUILD_USER_ID, EMAIL, etc.
When the assembly is started manually by the logged in user, this user ID is available in the environment variable BUILD_USER_ID
.
However, this environment variable will not be replaced / initialized when the assembly is automatically started by the Jenkins timer / scheduler.
Attached screenshot for details 
This problem can be solved by embedding the condition in the task using the conditional assembly stage plug-in / execution condition plug-in, where we can add a condition for each task to initialize the variable BUILD_USER_ID only when the assembly is called or started by a timer or scheduler, setting the condition using a regular expression ..
source share