Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-26010] Workflow compatibility #240

Merged
merged 51 commits into from Aug 15, 2015
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
07075f4
Workflow compatibility, stage 1
tfennelly Jul 10, 2015
a56938a
Getting rid of AbstractProject
tfennelly Jul 10, 2015
813c290
Added TODO on EventListener re possible use of ParameterizedJob
tfennelly Jul 10, 2015
6e87548
Upgrade rebuild-plugin
tfennelly Jul 10, 2015
fb4d4d8
Upgrade git-plugin
tfennelly Jul 10, 2015
53d52e3
AbstractBuild -> Run in core code (where possible)
tfennelly Jul 10, 2015
e67379d
Fix error spotted by @rsandell
tfennelly Jul 10, 2015
024782a
Get the tests to compile
tfennelly Jul 13, 2015
f84c610
Updated git-client plugin dep to v1.11.1
tfennelly Jul 13, 2015
ddb0822
Added commons-io dep (scope=provided)
tfennelly Jul 13, 2015
2031da3
Fixed checkstyle error in test class
tfennelly Jul 13, 2015
e8fb882
Fix DependencyQueueTaskDispatcherTest
tfennelly Jul 13, 2015
600865b
Fix BuildMemoryTest
tfennelly Jul 13, 2015
e431ff8
Fix MemoryImprintTest
tfennelly Jul 13, 2015
536e261
Fix Setup
tfennelly Jul 13, 2015
992bddf
Fix ParameterExpanderTest
tfennelly Jul 13, 2015
894cd47
Fix ToGerritRunListenerTest
tfennelly Jul 14, 2015
1544cc6
Fix EventListenerTest
tfennelly Jul 14, 2015
cccb9e8
Fix GerritTriggerTest
tfennelly Jul 14, 2015
b46b101
Fix ReplicationQueueTaskDispatcherTest
tfennelly Jul 14, 2015
4afc8df
Fix SpecGerritVerifiedSetterTest
tfennelly Jul 14, 2015
a12c41d
Checkstyle errors
tfennelly Jul 14, 2015
64ec1c9
Added job name to log
tfennelly Jul 14, 2015
ee96231
add actions to schedule2 for Workflow Jobs
jacob-keller Jul 14, 2015
4fe3786
Merge pull request #1 from jacob-keller/JENKINS-26010
tfennelly Jul 16, 2015
eb4a814
Added workflow 1.4 test dependency
tfennelly Jul 29, 2015
4af752b
Added simple workflow trigger test
tfennelly Jul 29, 2015
ac68390
Added check for gerrit parameters in test
tfennelly Jul 29, 2015
970e457
Get quitePeriod from ParameterizedJobMixIn.ParameterizedJob
tfennelly Jul 29, 2015
7a4b484
Fix PluginImpl.RETRIGGER to ref BUILD permission via `Item`
tfennelly Jul 29, 2015
0b8ff13
Added TODO: After 1.621, use ParameterizedJobMixIn.getTrigger
tfennelly Jul 29, 2015
8ef9a19
ToGerritRunListener.obtainFailureMessage log for non AbstractBuild types
tfennelly Jul 29, 2015
0982b25
Log the fact that modifying/deleting triggers is not a supported feat…
tfennelly Jul 29, 2015
78faddc
Removed ReplicationFailedHandler TODO. Not relevant.
tfennelly Jul 29, 2015
ecc8dca
Removed TODO comment
tfennelly Jul 29, 2015
93a64bc
Fixed ignored ToGerritRunListenerTest tests
tfennelly Jul 29, 2015
0c7f281
Fix checkstyle issues
tfennelly Jul 29, 2015
5321e90
Specified @deprecated versions of old methods on GerritMessageProvider
tfennelly Jul 29, 2015
24b63ce
@jglick was right, all it needed was to add the CauseAction
tfennelly Jul 30, 2015
1e76ce1
EventListener to use ParameterizedJobMixIn to schedule job
tfennelly Jul 30, 2015
7caf9fc
Get tests working again after move to use ParameterizedJobMixIn
tfennelly Jul 31, 2015
7c6e5aa
Get tests working again after move to use ParameterizedJobMixIn
tfennelly Jul 31, 2015
9d5ac2a
Checkstyle
tfennelly Jul 31, 2015
3dd663b
Test for Verified notification/label back to Gerrit Server
tfennelly Jul 31, 2015
0a19c16
GerritTrigger.DescriptorImpl.isApplicable to check for ParameterizedJob
tfennelly Aug 5, 2015
4ff2009
BuildMemory.Entry @WithBridgeMethods
tfennelly Aug 5, 2015
98a9148
TriggeredItemEntity @WithBridgeMethods
tfennelly Aug 5, 2015
00d41b6
Updates based on comments from @rsandell
tfennelly Aug 11, 2015
c3ce41f
Checkstyle (yawn)
tfennelly Aug 11, 2015
f55bd54
Fixed missing check for call to schedule2 ala @rsandell review
tfennelly Aug 14, 2015
c4f8562
<j:if test="${it.job instanceof hudson.model.AbstractProject}">
tfennelly Aug 14, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.565.3</version>
<version>1.580.1</version>
</parent>

<groupId>com.sonyericsson.hudson.plugins.gerrit</groupId>
Expand Down Expand Up @@ -69,19 +69,19 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>1.2.0</version>
<version>2.3</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git-client</artifactId>
<version>1.4.2</version>
<version>1.11.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.sonyericsson.hudson.plugins.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>1.22</version>
<version>1.25</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -95,6 +95,12 @@
<artifactId>commons-net</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down Expand Up @@ -158,6 +164,12 @@
<version>1.51</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
Expand Down
Expand Up @@ -3,7 +3,7 @@
import hudson.Extension;
import hudson.MarkupText;
import hudson.MarkupText.SubText;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.scm.ChangeLogAnnotator;
import hudson.scm.ChangeLogSet.Entry;

Expand All @@ -19,7 +19,7 @@
@Extension
public class ChangeIdAnnotator extends ChangeLogAnnotator {
@Override
public void annotate(AbstractBuild<?, ?> build, Entry change, MarkupText text) {
public void annotate(Run<?, ?> build, Entry change, MarkupText text) {
for (SubText token : text.findTokens(CHANGE_ID)) {
GerritCause gerritCause = build.getCause(GerritCause.class);
if (gerritCause != null
Expand Down
Expand Up @@ -28,7 +28,7 @@
import com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritCause;
import com.sonyericsson.rebuild.RebuildValidator;
import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.Run;

/**
* Disables the rebuild button for Gerrit triggered builds.
Expand All @@ -41,7 +41,7 @@ public class GerritRebuildValidator extends RebuildValidator {
private static final long serialVersionUID = 2704238052581467905L;

@Override
public boolean isApplicable(AbstractBuild build) {
public boolean isApplicable(Run build) {
return (build.getCause(GerritCause.class) != null);
}

Expand Down
Expand Up @@ -33,6 +33,7 @@
import hudson.Functions;
import hudson.RelativePath;
import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.Action;
import hudson.model.Describable;
import hudson.model.Failure;
Expand Down Expand Up @@ -904,7 +905,7 @@ private void rename(String newName) {
*
* @return the list of jobs configured with this server.
*/
public List<AbstractProject> getConfiguredJobs() {
public List<Job> getConfiguredJobs() {
return PluginImpl.getConfiguredJobs_(name);
}

Expand All @@ -914,14 +915,23 @@ public List<AbstractProject> getConfiguredJobs() {
* @param oldName the old name of the Gerrit server
*/
private void changeSelectedServerInJobs(String oldName) {
for (AbstractProject job : PluginImpl.getConfiguredJobs_(oldName)) {
GerritTrigger trigger = (GerritTrigger)job.getTrigger(GerritTrigger.class);
for (Job job : PluginImpl.getConfiguredJobs_(oldName)) {

if (!(job instanceof AbstractProject)) {
logger.info("Unable to modify Gerrit Trigger configurations for job [" + job.getName()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be warning instead of info

+ "] after Gerrit server has been renamed from [" + oldName + "] to [" + name + "]."
+ " This feature is only supported for AbstractProject types e.g. Freestyle Jobs.");
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if it's an instance of WorkflowJob?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does WorkflowJob have a way to add and remove triggers? I assume we'd want something similar to that? I know that the ParameterizedJobMixin does not have support for add triggers, but maybe we can just instanceOf to WorkflowJob here?

According to the source for WorkflowJob.java, it appears that WorkflowJob has an "addTrigger" function and getTriggers function, but this isn't exposed by the Mixin API. It would feel really awkward to instanceof and then use the same code both times.... Also, it doesn't support "getTrigger" standalone only the getTriggers...

Kind of ugly either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getTriggers() method is defined in ParameterizedJobMixIn.ParameterizedJob. We can cast to this one better than WorkflowJob.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amuniz At the moment, nothing will happen for a Workflow Job i.e. add/remove of triggers is not supported for workflow as things stand. That's why I marked it with a TODO. We need to find a way of handling it for workflow. AbstractProject has methods for adding and removing triggers, but that's no help for a Workflow job.

Trigger rename might be fixable by finding the current trigger and renaming the server on it Vs removing and readding the trigger (at the moment, rename is supported by removing the trigger and adding a new one). Not sure yet how remove will be supported (when a Gerrit server is removed we need to find all Jobs with triggers for that server and remove them).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add a trigger easily. It seems like the trigger add code will remove the old trigger already. Sadly WorkflowJob.java does not export a remove trigger function like the code does. Maybe we just don't bother removing the old trigger at all when a server is removed?

What's the reason that we actually have remove/add trigger code here specifically? I presume to prevent a bug? What do other trigger plugins do to prevent this sort of issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto removing zombie triggers after a Gerrit server is removed seems to make sense to me.

In any case (and imo), the debate on the pros and cons of programmatically removing a trigger is something that should happen separate to this PR. IMO, our job here is to integrate workflow and maintain the same feature set. It shouldn't be about proposing fundamental plugin design changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Jul 27, 2015 12:48 AM, "Tom Fennelly" notifications@github.com wrote:

In
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer.java:

@@ -914,14 +915,21 @@ private void rename(String newName) {
* @param oldName the old name of the Gerrit server
*/
private void changeSelectedServerInJobs(String oldName) {

  •    for (AbstractProject job :
    
    PluginImpl.getConfiguredJobs_(oldName)) {
  •        GerritTrigger trigger =
    
    (GerritTrigger)job.getTrigger(GerritTrigger.class);
  •    for (Job job : PluginImpl.getConfiguredJobs_(oldName)) {
    
  •        // TODO: find a way to handle add/remove of triggers
    
  •        if (!(job instanceof AbstractProject)) {
    
  •            return;
    

Auto removing zombie triggers after a Gerrit server is removed seems to
make sense to me.

In any case (and imo), the debate on the pros and cons of
programmatically removing a trigger is something that should happen
separate to this PR. IMO, our job here is to integrate workflow and
maintain the same feature set. It shouldn't be about proposing fundamental
plugin design changes.


Reply to this email directly or view it on GitHub.

While that is true.. I don't know of a good way to implement this
functionality and it may make sense to do the PR to remove such a feature
first unless we can actually do this change..

One way might be to optionally depend on work flow plug in. I have seen
others do this but I don't know how they did it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacob-keller Right, I didn't see a way of doing it for workflow. So, the easiest thing (for now) might be to mark it as a missing feature for Workflow jobs and not have that point block this PR?

Then, separately have a discussion on the merits/demerits etc of auto-removing triggers. This will either result in a task to remove the feature completely (for all build types), or a task to find a way of making it work for workflow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is fine myself. I would rather not block trigger support just
because we are missing a relatively minor feature.
On Jul 27, 2015 3:42 AM, "Tom Fennelly" notifications@github.com wrote:

In
src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/GerritServer.java
#240 (comment)
:

@@ -914,14 +915,21 @@ private void rename(String newName) {
* @param oldName the old name of the Gerrit server
*/
private void changeSelectedServerInJobs(String oldName) {

  •    for (AbstractProject job : PluginImpl.getConfiguredJobs_(oldName)) {
    
  •        GerritTrigger trigger = (GerritTrigger)job.getTrigger(GerritTrigger.class);
    
  •    for (Job job : PluginImpl.getConfiguredJobs_(oldName)) {
    
  •        // TODO: find a way to handle add/remove of triggers
    
  •        if (!(job instanceof AbstractProject)) {
    
  •            return;
    

@jacob-keller https://github.com/jacob-keller Right, I didn't see a way
of doing it for workflow. So, the easiest thing (for now) might be to mark
it as a missing feature for Workflow jobs and not have that point block
this PR?

Then, separately have a discussion on the merits/demerits etc of
auto-removing triggers. This will either result in a task to remove the
feature completely (for all build types), or a task to find a way of making
it work for workflow.


Reply to this email directly or view it on GitHub
https://github.com/jenkinsci/gerrit-trigger-plugin/pull/240/files#r35523862
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @tfennelly’s summary.

}
AbstractProject project = (AbstractProject)job;

GerritTrigger trigger = (GerritTrigger)project.getTrigger(GerritTrigger.class);
if (trigger != null) {
try {
trigger.setServerName(name);
trigger.start(job, false);
job.addTrigger(trigger);
job.save();
project.addTrigger(trigger);
project.save();
} catch (IOException e) {
logger.error("Error saving Gerrit Trigger configurations for job [" + job.getName()
+ "] after Gerrit server has been renamed from [" + oldName + "] to [" + name + "]");
Expand All @@ -934,11 +944,19 @@ private void changeSelectedServerInJobs(String oldName) {
* Remove "Gerrit event" as a trigger in all jobs selecting this server.
*/
private void removeGerritTriggerInJobs() {
for (AbstractProject job : getConfiguredJobs()) {
GerritTrigger trigger = (GerritTrigger)job.getTrigger(GerritTrigger.class);
for (Job job : getConfiguredJobs()) {

if (!(job instanceof AbstractProject)) {
logger.info("Unable to remove Gerrit Trigger ffrom job [" + job.getName() + "]. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning

+ " This feature is only supported for AbstractProject types e.g. Freestyle Jobs.");
return;
}
AbstractProject project = (AbstractProject)job;

GerritTrigger trigger = (GerritTrigger)project.getTrigger(GerritTrigger.class);
trigger.stop();
try {
job.removeTrigger(trigger.getDescriptor());
project.removeTrigger(trigger.getDescriptor());
} catch (IOException e) {
logger.error("Error removing Gerrit trigger from job [" + job.getName()
+ "]. Please check job config");
Expand Down
Expand Up @@ -36,7 +36,8 @@
import com.sonymobile.tools.gerrit.gerritevents.dto.attr.Provider;
import com.sonymobile.tools.gerrit.gerritevents.dto.events.GerritTriggeredEvent;
import hudson.Plugin;
import hudson.model.AbstractProject;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Api;
import hudson.model.Hudson;
import hudson.model.Items;
Expand Down Expand Up @@ -96,7 +97,7 @@ public class PluginImpl extends Plugin {
public static final Permission RETRIGGER = new Permission(PERMISSION_GROUP,
"Retrigger",
Messages._RetriggerPermissionDescription(),
AbstractProject.BUILD);
Item.BUILD);

private static final Logger logger = LoggerFactory.getLogger(PluginImpl.class);
private final List<GerritServer> servers = new CopyOnWriteArrayList<GerritServer>();
Expand Down Expand Up @@ -436,10 +437,10 @@ public static GerritHandler getHandler_() {
* @param serverName the name of the Gerrit server.
* @return the list of jobs configured with this server.
*/
public List<AbstractProject> getConfiguredJobs(String serverName) {
LinkedList<AbstractProject> configuredJobs = new LinkedList<AbstractProject>();
for (AbstractProject<?, ?> project : Hudson.getInstance().getItems(AbstractProject.class)) { //get the jobs
GerritTrigger gerritTrigger = project.getTrigger(GerritTrigger.class);
public List<Job> getConfiguredJobs(String serverName) {
LinkedList<Job> configuredJobs = new LinkedList<Job>();
for (Job<?, ?> project : Hudson.getInstance().getItems(Job.class)) { //get the jobs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherital sin: change Hudson to Jenkins

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherital sin: change Hudson to Jenkins

GerritTrigger gerritTrigger = GerritTrigger.getTrigger(project);

//if the job has a gerrit trigger, check whether the trigger has selected this server:
if (gerritTrigger != null && gerritTrigger.getServerName().equals(serverName)) {
Expand All @@ -458,7 +459,7 @@ public List<AbstractProject> getConfiguredJobs(String serverName) {
*/
@Nonnull
//CS IGNORE MethodName FOR NEXT 1 LINES. REASON: Static equivalent marker.
public static List<AbstractProject> getConfiguredJobs_(String serverName) {
public static List<Job> getConfiguredJobs_(String serverName) {
PluginImpl plugin = getInstance();
if (plugin == null) {
logger.debug("Error, plugin instance could not be found!");
Expand Down
Expand Up @@ -23,7 +23,7 @@
*/
package com.sonyericsson.hudson.plugins.gerrit.trigger.dependency;

import hudson.model.AbstractProject;
import hudson.model.Job;
import hudson.model.queue.CauseOfBlockage;

import java.util.List;
Expand All @@ -37,13 +37,13 @@
*/
public class BecauseDependentBuildIsBuilding extends CauseOfBlockage {

private List<AbstractProject> blockingProjects;
private List<Job> blockingProjects;

/**
* Standard constructor.
* @param blockingProjects The list of dependant builds which are blocking this one.
*/
public BecauseDependentBuildIsBuilding(List<AbstractProject> blockingProjects) {
public BecauseDependentBuildIsBuilding(List<Job> blockingProjects) {
this.blockingProjects = blockingProjects;
}

Expand Down
Expand Up @@ -25,11 +25,11 @@

import hudson.Extension;
import hudson.ExtensionList;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Cause;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Queue;
import hudson.model.Run;
import hudson.model.queue.QueueTaskDispatcher;
import hudson.model.queue.CauseOfBlockage;
import jenkins.model.Jenkins;
Expand Down Expand Up @@ -117,9 +117,9 @@ public static DependencyQueueTaskDispatcher getInstance() {

@Override
public CauseOfBlockage canRun(Queue.Item item) {
//AbstractProject check
if (!(item.task instanceof AbstractProject)) {
logger.debug("Not an abstract project: {}", item.task);
//Job check
if (!(item.task instanceof Job)) {
logger.debug("Not an Job instance: {}", item.task);
return null;
}

Expand All @@ -143,15 +143,15 @@ public CauseOfBlockage canRun(Queue.Item item) {
logger.debug("Item is already buildable");
return null;
}
AbstractProject p = (AbstractProject)item.task;
Job p = (Job)item.task;
GerritTrigger trigger = GerritTrigger.getTrigger(p);
//The project being checked has no Gerrit Trigger
if (trigger == null) {
logger.debug("Project does not contain a trigger");
return null;
}
//Dependency projects in the build queue
List<AbstractProject> dependencies = getProjectsFromString(trigger.getDependencyJobsNames(),
List<Job> dependencies = getProjectsFromString(trigger.getDependencyJobsNames(),
(Item)p);
if ((dependencies == null) || (dependencies.size() == 0)) {
logger.debug("No dependencies on project: {}", p);
Expand Down Expand Up @@ -182,7 +182,7 @@ public CauseOfBlockage canRun(Queue.Item item) {
}


List<AbstractProject> blockingProjects = getBlockingDependencyProjects(dependencies, event);
List<Job> blockingProjects = getBlockingDependencyProjects(dependencies, event);

if (blockingProjects.size() > 0) {
return new BecauseDependentBuildIsBuilding(blockingProjects);
Expand All @@ -198,12 +198,12 @@ public CauseOfBlockage canRun(Queue.Item item) {
* @param event The event should have also caused the blocking builds.
* @return the sublist of dependencies which need to be completed before this event is resolved.
*/
protected List<AbstractProject> getBlockingDependencyProjects(List<AbstractProject> dependencies,
protected List<Job> getBlockingDependencyProjects(List<Job> dependencies,
GerritTriggeredEvent event) {
List<AbstractProject> blockingProjects = new ArrayList<AbstractProject>();
List<Job> blockingProjects = new ArrayList<Job>();
ToGerritRunListener toGerritRunListener = ToGerritRunListener.getInstance();
if (toGerritRunListener != null) {
for (AbstractProject dependency : dependencies) {
for (Job dependency : dependencies) {
if (toGerritRunListener.isProjectTriggeredAndIncomplete(dependency, event)) {
blockingProjects.add(dependency);
}
Expand Down Expand Up @@ -232,8 +232,8 @@ private GerritCause getGerritCause(Queue.Item item) {
* @param context The context in which to read the string
* @return the list of projects
*/
public static List<AbstractProject> getProjectsFromString(String projects, Item context) {
List<AbstractProject> dependencyJobs = new ArrayList<AbstractProject>();
public static List<Job> getProjectsFromString(String projects, Item context) {
List<Job> dependencyJobs = new ArrayList<Job>();
if ((projects == null) || projects.equals("")) {
return null;
} else {
Expand All @@ -244,9 +244,9 @@ public static List<AbstractProject> getProjectsFromString(String projects, Item
String projectName = tokens.nextToken().trim();
if (!projectName.equals("")) {
Item item = jenkins.getItem(projectName, context, Item.class);
if ((item != null) && (item instanceof AbstractProject)) {
dependencyJobs.add((AbstractProject)item);
logger.debug("project dependency job added : {}", (AbstractProject)item);
if ((item != null) && (item instanceof Job)) {
dependencyJobs.add((Job)item);
logger.debug("project dependency job added : {}", (Job)item);
}
}
}
Expand Down Expand Up @@ -331,15 +331,15 @@ public void triggerScanDone(GerritEvent event) {
}

@Override
public void projectTriggered(GerritEvent event, AbstractProject project) {
public void projectTriggered(GerritEvent event, Job project) {
}

@Override
public void buildStarted(GerritEvent event, AbstractBuild build) {
public void buildStarted(GerritEvent event, Run build) {
}

@Override
public void buildCompleted(GerritEvent event, AbstractBuild build) {
public void buildCompleted(GerritEvent event, Run build) {
}

@Override
Expand Down
Expand Up @@ -28,16 +28,15 @@
import java.util.LinkedList;
import java.util.List;

import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;

import com.sonymobile.tools.gerrit.gerritevents.dto.GerritEvent;
import com.sonymobile.tools.gerrit.gerritevents.dto.attr.Change;
import com.sonymobile.tools.gerrit.gerritevents.dto.attr.PatchSet;
import com.sonymobile.tools.gerrit.gerritevents.dto.events.PatchsetCreated;
import com.sonyericsson.hudson.plugins.gerrit.trigger.events.lifecycle.GerritEventLifecycle;
import com.sonyericsson.hudson.plugins.gerrit.trigger.events.lifecycle.GerritEventLifecycleListener;

import hudson.model.Job;
import hudson.model.Run;
import net.sf.json.JSONObject;

/**
Expand Down Expand Up @@ -147,7 +146,7 @@ public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
}

@Override
public synchronized void fireProjectTriggered(final AbstractProject project) {
public synchronized void fireProjectTriggered(final Job project) {
fireEvent(new ListenerVisitor() {
@Override
public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
Expand All @@ -157,7 +156,7 @@ public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
}

@Override
public synchronized void fireBuildStarted(final AbstractBuild build) {
public synchronized void fireBuildStarted(final Run build) {
fireEvent(new ListenerVisitor() {
@Override
public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
Expand All @@ -167,7 +166,7 @@ public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
}

@Override
public synchronized void fireBuildCompleted(final AbstractBuild build) {
public synchronized void fireBuildCompleted(final Run build) {
fireEvent(new ListenerVisitor() {
@Override
public void visit(GerritEventLifecycleListener listener, GerritEvent event) {
Expand Down