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

Add function to remove trigger #126

Merged
merged 5 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,17 @@ public List<TriggerDescriptor> getTriggerDescriptors() {
}

public void addTrigger(Trigger trigger) {
removeTrigger(trigger);
triggers.add(trigger);
trigger.start(this, true);
}

public void removeTrigger(Trigger trigger) {
LinuxSuRen marked this conversation as resolved.
Show resolved Hide resolved
Trigger old = triggers.get(trigger.getDescriptor());
if (old != null) {
old.stop();
triggers.remove(old);
}
triggers.add(trigger);
trigger.start(this, true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ public void triggersRoundtrip() throws Exception {

}

@Test
public void cleanTriggers() throws Exception {
SampleComputedFolder s = r.jenkins.createProject(SampleComputedFolder.class, "s");
s.addTrigger(new PeriodicFolderTrigger("30m"));
LinuxSuRen marked this conversation as resolved.
Show resolved Hide resolved

s.removeTrigger(new PeriodicFolderTrigger("30m"));

assertEquals(0, s.getTriggers().size());
}

@Test
@Issue("JENKINS-42511")
public void concurrentEvents() throws Exception {
Expand Down