Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Trigger user Cannot invoke method getFullName() on null object #3983

fcb_0817 ·

Hi,

I want to get the trigger user to check if it's triggered by user or scheduler with the method of user.getFullName().

If it's triggered by user, build configuration finished successfully. If it's triggered by scheduler, it threw below exception:

14:11:03,710 ERROR - Step 'master>IsWho' is failed: java.lang.NullPointerException: Cannot invoke method getFullName() on null object
at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at script15355230634571627701421.run(script15355230634571627701421.groovy:22)
at com.pmease.quickbuild.plugin.basis.BasisPlugin$30.evaluate(BasisPlugin.java:365)
at com.pmease.quickbuild.DefaultScriptEngine.evaluate(DefaultScriptEngine.java:305)
at com.pmease.quickbui...

-step setting----------------------
groovy:
if(user.getFullName())
{
logger.info("is not NULL");
logger.info(user.getFullName());
}
else
{
logger.info("is NULL");
}


My setting is not correct? Is there any good method to get the either trigger user or scheduler?

Thanks,

fcb

  • solved #4
  • replies 4
  • views 1524
  • stars 1
fcb_0817 ·

I tried if(user.getFullName()!=null) but still failed.

narwhal ·

i recall doing this before and how i solved it had to do with checking the user id first instead. I believe scheduler is always id 0 or -1. edit: but yes I have encountered this problem. The problem exists in the REST API as well.

robinshen ADMIN ·

If triggered by scheduler, the user will be null. So to check if a build is triggered by an user, use below script:

user != null

Or this script:

!request.isScheduled()

fcb_0817 ·

Thank you, Robinshen. It works on my build.