diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java
index 0649bdb33b10..5bd1d6a02d79 100644
--- a/core/src/main/java/hudson/model/AbstractItem.java
+++ b/core/src/main/java/hudson/model/AbstractItem.java
@@ -937,6 +937,7 @@ public void updateByXml(Source source) throws IOException {
// if everything went well, commit this new version
out.commit();
SaveableListener.fireOnChange(this, getConfigFile());
+ ItemListener.fireOnUpdated(this);
} finally {
out.abort(); // don't leave anything behind
diff --git a/test/src/test/java/hudson/model/listeners/ItemListenerTest.java b/test/src/test/java/hudson/model/listeners/ItemListenerTest.java
index 6209790f1a97..b7147d3ebfe5 100644
--- a/test/src/test/java/hudson/model/listeners/ItemListenerTest.java
+++ b/test/src/test/java/hudson/model/listeners/ItemListenerTest.java
@@ -35,6 +35,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
/**
@@ -58,6 +59,12 @@ public void setUp() {
@Override public void onCopied(Item src, Item item) {
events.append('Y');
}
+
+ @Override
+ public void onUpdated(Item item) {
+ events.append('U');
+ }
+
};
ItemListener.all().add(0, listener);
}
@@ -71,4 +78,18 @@ public void onCreatedViaCLI() {
assertNotNull("job should be created: " + result, j.jenkins.getItem("testJob"));
assertEquals("onCreated event should be triggered: " + result, "C", events.toString());
}
+
+ @Issue("JENKINS-64553")
+ @Test
+ public void onUpdatedViaCLI() {
+ CLICommandInvoker.Result result = new CLICommandInvoker(j, "create-job").
+ withStdin(new ByteArrayInputStream("".getBytes(Charset.defaultCharset()))).
+ invokeWithArgs("testJob");
+ assertThat(result, CLICommandInvoker.Matcher.succeeded());
+ result = new CLICommandInvoker(j, "update-job").
+ withStdin(new ByteArrayInputStream("".getBytes(Charset.defaultCharset()))).
+ invokeWithArgs("testJob");
+ assertThat(result, CLICommandInvoker.Matcher.succeeded());
+ assertEquals("onUpdated event should be triggered: " + result, "CU", events.toString());
+ }
}