Skip to content

Commit

Permalink
Merge pull request #27 from jenkinsci/ephemeral
Browse files Browse the repository at this point in the history
[JENKINS-22639] Don't record changes to AbstractCloudSlaves or Ephemeral Nodes
  • Loading branch information
Stefan Brausch committed Sep 25, 2014
2 parents ba17eff + e410332 commit e9c4b00
Showing 1 changed file with 15 additions and 4 deletions.
Expand Up @@ -5,6 +5,8 @@
package hudson.plugins.jobConfigHistory;

import hudson.Extension;
import hudson.slaves.EphemeralNode;
import hudson.slaves.AbstractCloudSlave;
import hudson.slaves.ComputerListener;
import hudson.model.Node;
import hudson.model.Slave;
Expand Down Expand Up @@ -49,19 +51,28 @@ public void onConfigurationChange() {
*/
private void onAdd() {
for (Node node : Jenkins.getInstance().getNodes()) {
if (!nodes.contains(node)) {
if (!nodes.contains(node) && isTracked(node)) {
switchHistoryDao(node).createNewNode(node);
return;
}
}
}

/**
* Is this node likely to be important to the user?
* @param node
*/
private boolean isTracked(Node node) {
return node != null &&
! (node instanceof AbstractCloudSlave || node instanceof EphemeralNode);
}

/**
* If a slave get removed.
*/
private void onRemove() {
for (Node node : nodes) {
if (!Jenkins.getInstance().getNodes().contains(node)) {
if (!Jenkins.getInstance().getNodes().contains(node) && isTracked(node)) {
switchHistoryDao(node).deleteNode(node);
return;
}
Expand All @@ -87,7 +98,7 @@ private void onChange() {
private void onRename() {
Node originalNode = null;
for (Node node : nodes) {
if (!Jenkins.getInstance().getNodes().contains(node)) {
if (!Jenkins.getInstance().getNodes().contains(node) && isTracked(node)) {
originalNode = node;
}
}
Expand All @@ -97,7 +108,7 @@ private void onRename() {
}
Node newNode = null;
for (Node node : Jenkins.getInstance().getNodes()) {
if (!nodes.contains(node)) {
if (!nodes.contains(node) && isTracked(node)) {
newNode = node;
}
}
Expand Down

0 comments on commit e9c4b00

Please sign in to comment.