Skip to content

Commit

Permalink
[FIXED JENKINS-45460] Allow adding triggers after migration.
Browse files Browse the repository at this point in the history
Before this, if you had triggers configured before upgrading from a
version that didn't yet have PipelineTriggersJobProperty,
PipelineTriggersJobProperty.setTriggers(List) was called via
WorkflowJob.onLoad with the old DescribableList triggers.toList() -
which returns an UnmodifiableList. Oops.
  • Loading branch information
abayer committed Aug 3, 2017
1 parent e458691 commit 7b9b836
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -71,7 +71,7 @@ public PipelineTriggersJobProperty(List<Trigger> triggers) {
}

public void setTriggers(List<Trigger<?>> triggers) {
this.triggers = triggers;
this.triggers.addAll(triggers);
}

public List<Trigger<?>> getTriggers() {
Expand Down
Expand Up @@ -141,6 +141,14 @@ public void triggerMigration() throws Exception {

assertNotNull(((MockTrigger)mockFromProp).currentStatus());
assertEquals("[null, false, null, false, null, false]", MockTrigger.startsAndStops.toString());

// Verify that we can replace an existing trigger.
Trigger newTimerTrigger = new TimerTrigger("@hourly");

p.addTrigger(newTimerTrigger);

Trigger newTimerFromJob = p.getTriggers().get(newTimerTrigger.getDescriptor());
assertEquals(newTimerTrigger.getSpec(), newTimerFromJob.getSpec());
}

@Test
Expand Down

0 comments on commit 7b9b836

Please sign in to comment.