Skip to content

Commit

Permalink
Provide the old trigger object when configuring a new timer trigger
Browse files Browse the repository at this point in the history
This allows the slice implementor to copy any values that are not
of interest to the given slice.  This was motivated by the bug
[JENKINS-29941], and this commit includes a fix for that bug.
  • Loading branch information
mdonohue committed Sep 18, 2015
1 parent 120e5ee commit 7474a28
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Expand Up @@ -52,7 +52,7 @@ public static List<String> getValues(Trigger trigger) {
return TopLevelItemSelector.getAllTopLevelItems(AbstractProject.class);
}

public abstract Trigger newTrigger(String spec) throws ANTLRException;
public abstract Trigger newTrigger(String spec, Trigger oldTrigger) throws ANTLRException;

public boolean setValues(AbstractProject<?, ?> item, List<String> set) {
if (set.isEmpty())
Expand All @@ -76,7 +76,7 @@ public boolean setValues(AbstractProject<?, ?> item, List<String> set) {
try {
Trigger newtrigger = null;
if (!disabled) {
newtrigger = newTrigger(spec);
newtrigger = newTrigger(spec, oldTrigger);
}
if (oldTrigger != null) {
item.removeTrigger(oldTrigger.getDescriptor());
Expand Down
Expand Up @@ -28,8 +28,12 @@ public String getUrl() {
}

@SuppressWarnings("unchecked")
public Trigger newTrigger(String spec) throws ANTLRException {
return new SCMTrigger(spec);
public Trigger newTrigger(String spec, Trigger oldTrigger) throws ANTLRException {
boolean ignorePostCommitHooks = false;
if(oldTrigger instanceof SCMTrigger) {
ignorePostCommitHooks = ((SCMTrigger)oldTrigger).isIgnorePostCommitHooks();
}
return new SCMTrigger(spec, ignorePostCommitHooks);
}

}
Expand Down
Expand Up @@ -28,8 +28,8 @@ public String getUrl() {
}

@SuppressWarnings("unchecked")
public Trigger newTrigger(String spec) throws ANTLRException {
return new TimerTrigger(spec);
public Trigger newTrigger(String spec, Trigger oldTrigger) throws ANTLRException {
return new TimerTrigger(spec);
}

}
Expand Down

0 comments on commit 7474a28

Please sign in to comment.