Navigation Menu

Skip to content

Commit

Permalink
[FIXED JENKINS-11649]
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob_robertson committed Nov 9, 2011
1 parent 56d5cda commit d2af6a1
Showing 1 changed file with 72 additions and 12 deletions.
Expand Up @@ -28,11 +28,37 @@ public Count() {
super(new LogRotationBuildsSliceSpec());
}
}
@Extension
public static class ArtifactDays extends LogRotationSlicer {
public ArtifactDays() {
super(new ArtifactDaysSliceSpec());
}
}
@Extension
public static class ArtifactBuilds extends LogRotationSlicer {
public ArtifactBuilds() {
super(new ArtifactBuildsSliceSpec());
}
}

protected abstract static class AbstractLogRotationSliceSpec extends UnorderedStringSlicerSpec<AbstractProject<?,?>> {
private static final String DISABLED = "(Disabled)";

public String getDefaultValueString() {
private String displayName;
private String url;

public AbstractLogRotationSliceSpec(String displayName, String url) {
this.displayName = "Discard Old Builds Slicer - " + displayName;
this.url = url;
}
@Override
public String getName() {
return displayName;
}
@Override
public String getUrl() {
return url;
}
public String getDefaultValueString() {
return DISABLED;
}
public String getName(AbstractProject<?, ?> item) {
Expand Down Expand Up @@ -88,6 +114,8 @@ public boolean setValues(AbstractProject<?, ?> item, Set<String> set) {
}
days = getNewDays(days, newInt);
builds = getNewBuilds(builds, newInt);
artifactDaysToKeep = getNewArtifactDays(artifactDaysToKeep, newInt);
artifactNumToKeep = getNewArtifactBuilds(artifactNumToKeep, newInt);

LogRotator newlogrotator = new LogRotator(days, builds, artifactDaysToKeep, artifactNumToKeep);

Expand All @@ -110,14 +138,17 @@ protected int getNewDays(int oldDays, int newValue) {
protected int getNewBuilds(int oldBuilds, int newValue) {
return oldBuilds;
}
protected int getNewArtifactDays(int oldValue, int newValue) {
return oldValue;
}
protected int getNewArtifactBuilds(int oldValue, int newValue) {
return oldValue;
}
}

public static class LogRotationDaysSliceSpec extends AbstractLogRotationSliceSpec {
public String getName() {
return "Discard Old Builds Slicer - Days";
}
public String getUrl() {
return "logrotationdays";
public LogRotationDaysSliceSpec() {
super("Days to keep builds", "logrotationdays");
}
@Override
protected String getValue(LogRotator rotator) {
Expand All @@ -129,11 +160,8 @@ protected int getNewDays(int oldDays, int newValue) {
}
}
public static class LogRotationBuildsSliceSpec extends AbstractLogRotationSliceSpec {
public String getName() {
return "Discard Old Builds Slicer - Builds";
}
public String getUrl() {
return "logrotationbuilds";
public LogRotationBuildsSliceSpec() {
super("Max # of builds to keep", "logrotationbuilds");
}
@Override
protected String getValue(LogRotator rotator) {
Expand All @@ -144,6 +172,32 @@ protected int getNewBuilds(int oldBuilds, int newValue) {
return newValue;
}
}
public static class ArtifactDaysSliceSpec extends AbstractLogRotationSliceSpec {
public ArtifactDaysSliceSpec() {
super("Days to keep artifacts", "artifactsdays");
}
@Override
protected String getValue(LogRotator rotator) {
return rotator.getArtifactDaysToKeepStr();
}
@Override
protected int getNewArtifactDays(int oldDays, int newValue) {
return newValue;
}
}
public static class ArtifactBuildsSliceSpec extends AbstractLogRotationSliceSpec {
public ArtifactBuildsSliceSpec() {
super("Max # of builds to keep with artifacts", "artifactsbuilds");
}
@Override
protected String getValue(LogRotator rotator) {
return rotator.getArtifactNumToKeepStr();
}
@Override
protected int getNewArtifactBuilds(int oldValue, int newValue) {
return newValue;
}
}
public static boolean equals(LogRotator r1, LogRotator r2) {
if (r1 == r2) {
return true;
Expand All @@ -157,6 +211,12 @@ public static boolean equals(LogRotator r1, LogRotator r2) {
if (r1.getNumToKeep() != r2.getNumToKeep()) {
return false;
}
if (r1.getArtifactDaysToKeep() != r2.getArtifactDaysToKeep()) {
return false;
}
if (r1.getArtifactNumToKeep() != r2.getArtifactNumToKeep()) {
return false;
}
return true;
}
}

0 comments on commit d2af6a1

Please sign in to comment.