From 5384f28dfd66bdb1839935802aa6769ee55849d2 Mon Sep 17 00:00:00 2001
From: Trygve Laugstøl <trygvis@inamo.no>
Date: Sat, 10 May 2014 19:42:52 +0200
Subject: o Making sure that the MVEL expression is configured when starting.

---
 .../jenkinsci/plugins/activemq/ActiveMqBuildTrigger.java   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

(limited to 'src/main')

diff --git a/src/main/java/org/jenkinsci/plugins/activemq/ActiveMqBuildTrigger.java b/src/main/java/org/jenkinsci/plugins/activemq/ActiveMqBuildTrigger.java
index f3a2a79..9f9c6a6 100644
--- a/src/main/java/org/jenkinsci/plugins/activemq/ActiveMqBuildTrigger.java
+++ b/src/main/java/org/jenkinsci/plugins/activemq/ActiveMqBuildTrigger.java
@@ -1,13 +1,12 @@
 package org.jenkinsci.plugins.activemq;
 
 import hudson.Extension;
+import hudson.model.AbstractProject;
 import hudson.model.BuildableItem;
 import hudson.model.Item;
 import hudson.triggers.Trigger;
 import hudson.triggers.TriggerDescriptor;
-import hudson.util.FormValidation;
 import org.kohsuke.stapler.DataBoundConstructor;
-import org.kohsuke.stapler.QueryParameter;
 import org.mvel2.MVEL;
 import org.slf4j.Logger;
 
@@ -20,7 +19,7 @@ import static org.jenkinsci.plugins.activemq.ActiveMqClient.BuildRequest;
 import static org.mvel2.MVEL.compileExpression;
 import static org.slf4j.LoggerFactory.getLogger;
 
-public class ActiveMqBuildTrigger extends Trigger<BuildableItem> {
+public class ActiveMqBuildTrigger extends Trigger<AbstractProject> {
 
     private static final Logger log = getLogger(ActiveMqBuildTrigger.class);
 
@@ -28,10 +27,15 @@ public class ActiveMqBuildTrigger extends Trigger<BuildableItem> {
 
     private transient Serializable compiledMvel;
 
-    // parameters['jobName'] == 'fast-build'
     @DataBoundConstructor
     public ActiveMqBuildTrigger(String mvel) {
         log.info("ActiveMqBuildTrigger.ActiveMqBuildTrigger");
+    }
+
+    @Override
+    public void start(AbstractProject project, boolean newInstance) {
+        super.start(project, newInstance);
+        log.info("ActiveMqBuildTrigger.start");
         setMvel_(mvel);
     }
 
@@ -43,6 +47,7 @@ public class ActiveMqBuildTrigger extends Trigger<BuildableItem> {
     private void setMvel_(String mvel) {
         mvel = trimToNull(mvel);
         if (mvel == null) {
+            log.info("ActiveMqBuildTrigger.setMvel_: mvel is null");
             this.mvel = null;
             this.compiledMvel = null;
             return;
@@ -51,6 +56,7 @@ public class ActiveMqBuildTrigger extends Trigger<BuildableItem> {
         try {
             compiledMvel = compileExpression(mvel);
             this.mvel = mvel;
+            log.info("ActiveMqBuildTrigger.setMvel_: mvel={}", mvel);
         } catch (Exception e) {
             log.warn("Unable to compile MVEL", e);
         }
-- 
cgit v1.2.3