Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JENKINS-25457 Server error when viewing pipeline with NOT_BUILT result #87

Merged
merged 1 commit into from Nov 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -102,6 +102,12 @@ public boolean isCancelled() {
return CANCELLED.equals(type);
}

@Override
public boolean isNotBuilt() {
return NOT_BUILT.equals(type);
}


@Override
public boolean isDisabled() {
return DISABLED.equals(type);
Expand Down Expand Up @@ -140,9 +146,11 @@ public static Status resolveStatus(AbstractProject project, AbstractBuild build,
}
if (Result.UNSTABLE.equals(result)) {
return StatusFactory.unstable(build.getTimeInMillis(), build.getDuration());
} else {
throw new IllegalStateException("Result " + result + " not recognized.");
}
if (Result.NOT_BUILT.equals(result)) {
return StatusFactory.notBuilt(build.getTimeInMillis(), build.getDuration());
}
throw new IllegalStateException("Result " + result + " not recognized.");
}


Expand Down
Expand Up @@ -40,6 +40,8 @@ public interface Status {

boolean isDisabled();

boolean isNotBuilt();

long getLastActivity();

String getTimestamp();
Expand Down
Expand Up @@ -49,6 +49,9 @@ public static Status unstable(long lastActivity, long duration) {
public static Status cancelled(long lastActivity, long duration) {
return new SimpleStatus(StatusType.CANCELLED, lastActivity, duration);
}
public static Status notBuilt(long lastActivity, long duration) {
return new SimpleStatus(StatusType.NOT_BUILT, lastActivity, duration);
}

public static Status disabled() {
return new SimpleStatus(StatusType.DISABLED, -1, -1);
Expand Down
Expand Up @@ -18,5 +18,5 @@
package se.diabol.jenkins.pipeline.domain.status;

public enum StatusType {
IDLE, RUNNING, QUEUED, SUCCESS, UNSTABLE, FAILED, CANCELLED, DISABLED
IDLE, RUNNING, QUEUED, SUCCESS, UNSTABLE, FAILED, CANCELLED, DISABLED, NOT_BUILT
}
7 changes: 7 additions & 0 deletions src/main/webapp/pipeline-common.css
Expand Up @@ -219,6 +219,13 @@ div.task-progress-running {
font-weight: bold;
}

.NOT_BUILT {
border-left: 6px solid #8b8989;
background-color: #d3d3d3;
font-weight: bold;
}


.DISABLED {
border-left: 6px solid transparent;
color: #a9a9a9;
Expand Down
6 changes: 6 additions & 0 deletions src/main/webapp/pipeline-fullscreen.css
Expand Up @@ -107,6 +107,12 @@ div.task-progress {
background-color: inherit;
}

.NOT_BUILT {
border-left: 6px solid #8b8989;
font-weight: bold;
background-color: inherit;
}

.DISABLED {
border-left: 6px solid transparent;
color: #a9a9a9;
Expand Down
Expand Up @@ -39,7 +39,6 @@
import java.util.List;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

@RunWith(MockitoJUnitRunner.class)
public class SimpleStatusTest {
Expand Down Expand Up @@ -118,7 +117,6 @@ public void testResolveStatusUnstable() throws Exception {
}



@Test
public void testResolveStatusAborted() throws Exception {
FreeStyleProject project = jenkins.createFreeStyleProject();
Expand All @@ -136,16 +134,17 @@ public void testResolveStatusAborted() throws Exception {

@Test
public void testResolveStatusNotBuilt() throws Exception {
//Result.NOT_BUILT should never occur for a build, just for a module within a maven build.
FreeStyleProject project = jenkins.createFreeStyleProject();
project.getBuildersList().add(new MockBuilder(Result.NOT_BUILT));
project.scheduleBuild2(0);
jenkins.waitUntilNoActivity();
try {
SimpleStatus.resolveStatus(project, project.getLastBuild(), null);
fail("Should throw exception here");
} catch (IllegalStateException e) {
}
Status status = SimpleStatus.resolveStatus(project, project.getLastBuild(), null);
assertTrue(status.isNotBuilt());
assertEquals("NOT_BUILT", status.toString());
assertEquals(project.getLastBuild().getTimeInMillis(), status.getLastActivity());
assertEquals(project.getLastBuild().getDuration(), status.getDuration());
assertNotNull(status.getTimestamp());
assertTrue(status.getType().equals(StatusType.NOT_BUILT));
}


Expand Down
Expand Up @@ -35,13 +35,14 @@ public void testValueOf() {
assertEquals(StatusType.RUNNING, StatusType.valueOf("RUNNING"));
assertEquals(StatusType.SUCCESS, StatusType.valueOf("SUCCESS"));
assertEquals(StatusType.UNSTABLE, StatusType.valueOf("UNSTABLE"));
assertEquals(StatusType.NOT_BUILT, StatusType.valueOf("NOT_BUILT"));
}

@Test
public void testValue() {
StatusType[] values = StatusType.values();
assertNotNull(values);
assertEquals(8, values.length);
assertEquals(9, values.length);
}

}