Null pointer exception thrown by createBuildCustomizer

Answered

I am trying to create a trigger that modifies the parametes of the job it triggers (allowing a user to pass paramters to a job from a trigger)

I am currently stuck getting a BuildCustomizer object. I am passing createBuildCustomizer null for SUser (as it's nullable), but and recipving a nullpointer exception:

   public void triggerBuild(@NotNull PolledTriggerContext context) throws BuildTriggerException {

        try{

            logger.info("triggerBuild start");
            logger.info("Triggered by : " + context.getBuildType().getName());

            logger.info("Tigger properties : " + context.getTriggerDescriptor().getProperties().toString());
            SBuildType buildType = context.getBuildType();
            logger.info("HERE! : ");
            Map<String,String> triggerProperties = context.getTriggerDescriptor().getProperties();
            
            BuildCustomizer buildCustomiser = customizerFactory.createBuildCustomizer(buildType, null);  //throws here!!

 

 

 

 

Exception:

[2016-04-06 11:49:56,038]   INFO - arameterizedBuildTriggerPolicy - Caught Exception + java.lang.NullPointerException: null
     at com.snsystems.teamcity.plugins.parameterizedBuildTrigger.ParameterizedBuildTriggerPolicy.triggerBuild(ParameterizedBuildTriggerPolicy.java:52)
     at jetbrains.buildServer.serverSide.impl.BuildTriggersChecker$4.run(BuildTriggersChecker.java:2)
     at jetbrains.buildServer.util.NamedThreadFactory.executeWithNewThreadName(NamedThreadFactory.java:89)
     at jetbrains.buildServer.serverSide.impl.BuildTriggersChecker.callTrigger(BuildTriggersChecker.java:121)
     at jetbrains.buildServer.serverSide.impl.BuildTriggersChecker.access$1100(BuildTriggersChecker.java:77)
     at jetbrains.buildServer.serverSide.impl.BuildTriggersChecker$BuildTriggersGroup.processTriggers(BuildTriggersChecker.java:13)
     at jetbrains.buildServer.serverSide.impl.BuildTriggersChecker.triggerBuilds(BuildTriggersChecker.java:104)
     at jetbrains.buildServer.serverSide.impl.BuildServerRunner$4.doSomething(BuildServerRunner.java:2)
     at jetbrains.buildServer.serverSide.impl.BuildServerRunner$BuildServerWorker.runAction(BuildServerRunner.java:10)
     at jetbrains.buildServer.serverSide.impl.BuildServerRunner$BuildServerWorker.run(BuildServerRunner.java:48)
     at java.lang.Thread.run(Thread.java:745)

 

 

What I really don't understand is that it seems to work in all these plugins:

https://github.com/Saulis/teamcity-gerrit-trigger/blob/master/teamcity-gerrit-trigger-server/src/main/java/org/saulis/GerritPolledBuildTrigger.java

https://github.com/ArcBees/teamcity-plugins/blob/master/pullrequests/src/main/java/com/arcbees/pullrequest/PullRequestsTrigger.java

https://github.com/leo-from-spb/teamcity-wbb/blob/master/server/src/org/jetbrains/teamcity/wbb/WbbBuildStarter.java

http://www.programcreek.com/java-api-examples/index.php?source_dir=tc-bisect-master/bisectPlugin/bisectPlugin-server/src/main/java/org/tkirill/teamcity/bisectPlugin/BisectBuildTriggerHelper.java

 

Would anyone be able to tell me what I'm doing wrong?

Cheers,

Tim

 

2 comments

I am using Teamcity 9.1.4 and Java 1.6.

0

Sorry found out the exception was thrown because the 'customizerFactory' was null.

For completeness this was due to be passing in a null value in my BuildTriggerService.getBuildTriggeringPolicy implementation.

0

Please sign in to leave a comment.