Skip to content

Commit

Permalink
Fixed JENKINS-21068, implemented better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen authored and inky84 committed Dec 18, 2013
1 parent 47ce865 commit 8e6412f
Show file tree
Hide file tree
Showing 26 changed files with 143 additions and 334 deletions.
41 changes: 13 additions & 28 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.484</version>
<version>1.509</version>
</parent>

<groupId>net.praqma</groupId>
Expand All @@ -28,20 +28,14 @@
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.11</version>
</dependency>
</dependencies>
<version>2.16</version>
</plugin>
</plugins>

Expand All @@ -50,7 +44,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<version>2.16</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down Expand Up @@ -86,7 +80,6 @@
<profiles>
<profile>
<id>static</id>
<!-- Skip tests for static analysis -->
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
Expand All @@ -113,7 +106,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.10</version>
<version>2.11</version>
<configuration>
<enableRulesSummary>false</enableRulesSummary>
</configuration>
Expand Down Expand Up @@ -147,21 +140,6 @@
</execution>
</executions>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javancss-maven-plugin</artifactId>
Expand Down Expand Up @@ -404,6 +382,13 @@
</scm>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
<artifactId>praqmajutils</artifactId>
Expand Down Expand Up @@ -438,13 +423,13 @@
<version>2.3.1.201302201838-r</version>
</dependency>


<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
Expand Down
Expand Up @@ -42,13 +42,7 @@ public boolean isFixed() {

public abstract String prettyPrint();


/*
*
* Feed specifics
*
*/

@Override
public File getFeedFile( File path ) {
return new File( path, ConfigurationRotatorReport.urlTtransform( getComponentName() ) + ".xml" );
}
Expand All @@ -61,7 +55,8 @@ public Feed getFeed( File feedFile, String url, Date updated ) throws FeedExcept

return feed;
}


@Override
public Entry getFeedEntry( AbstractBuild<?, ?> build, Date updated ) {
ConfigurationRotatorBuildAction action = build.getAction( ConfigurationRotatorBuildAction.class );
AbstractConfiguration configuration = action.getConfigurationWithOutCast();
Expand Down
Expand Up @@ -206,8 +206,7 @@ public void printConfiguration(PrintStream out, AbstractConfiguration cfg) {
* @throws IOException
* @throws ConfigurationRotatorException
* @throws InterruptedException
*/
//public abstract void writeChangeLog( File changeLogFile, BuildListener listener, AbstractBuild<?, ?> build ) throws IOException, ConfigurationRotatorException, InterruptedException;
*/
public abstract AbstractConfigurationRotatorSCM.ChangeLogWriter getChangeLogWriter(File changeLogFile, BuildListener listener, AbstractBuild<?, ?> build);

public abstract class ChangeLogWriter<C extends AbstractConfigurationComponent, T extends AbstractConfiguration<C>> {
Expand Down
Expand Up @@ -40,19 +40,9 @@ public class ConfigurationRotator extends SCM {
private static Logger logger = Logger.getLogger( ConfigurationRotator.class.getName() );

public enum ResultType {

/*
* Tested and configuration is compatible
*/
COMPATIBLE,

/*
* Tested and configuration is NOT compatible
*/
INCOMPATIBLE,

FAILED,

/*
* The tests failed and was unable to determine compatibility
*/
Expand Down Expand Up @@ -164,8 +154,7 @@ public boolean checkout( AbstractBuild<?, ?> build, Launcher launcher, FilePath

}
} catch( Exception e ) {
logger.log( Level.SEVERE, "Unable to create configuration", e );
e.printStackTrace( out );
logger.log( Level.SEVERE, "Unable to create configuration", e );
DiedBecauseAction da = new DiedBecauseAction( e.getMessage(), DiedBecauseAction.Die.die );
build.addAction( da );
throw new AbortException( e.getMessage() );
Expand Down
Expand Up @@ -32,8 +32,7 @@ public Class<?> getClazz() {
public void doReset( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
SCM scm = build.getProject().getScm();
if( scm instanceof ConfigurationRotator ) {
((ConfigurationRotator)scm).setConfigurationByAction( build.getProject(), this );
//rsp.forwardToPreviousPage( req. );
((ConfigurationRotator)scm).setConfigurationByAction( build.getProject(), this );
rsp.sendRedirect( "../../" );
} else {
rsp.sendError( StaplerResponse.SC_BAD_REQUEST, "Not a Configuration Rotator job" );
Expand Down
Expand Up @@ -17,9 +17,7 @@
import java.util.logging.Logger;

public abstract class ConfigurationRotatorFeedAction implements Action {

private static Logger logger = Logger.getLogger( ConfigurationRotatorFeedAction.class.getName() );


@Override
public String getIconFileName() {
return null;
Expand Down Expand Up @@ -74,7 +72,6 @@ public ArrayList<File> getComponents( FileFilter filter ) {
return list;
}


public void doFeed( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
String component = req.getParameter( "component" );
File file = new File( new File( ConfigurationRotator.getFeedPath(), getComponentName() ), component + ".xml" );
Expand Down
Expand Up @@ -7,48 +7,49 @@
import java.util.ArrayList;

public class ConfigurationRotatorProjectAction implements ProminentProjectAction {
private final AbstractProject<?, ?> project;

public ConfigurationRotatorProjectAction( AbstractProject<?, ?> project ) {
this.project = project;
}

@Override
public String getIconFileName() {
return "/plugin/config-rotator/images/rotate.png";
}

@Override
public String getDisplayName() {
return "Config Rotator";
}

@Override
public String getUrlName() {
return "config-rotator";
}

private final AbstractProject<?, ?> project;

public ConfigurationRotatorProjectAction(AbstractProject<?, ?> project) {
this.project = project;
}

@Override
public String getIconFileName() {
return "/plugin/config-rotator/images/rotate.png";
}

@Override
public String getDisplayName() {
return "Config Rotator";
}

@Override
public String getUrlName() {
return "config-rotator";
}

/**
* New method extracts the latest builds.
*
* @param number
* @return
* @return
*/
public ArrayList<ConfigurationRotatorBuildAction> getLastActions(int number) {
SCM scm = project.getScm();
if( scm instanceof ConfigurationRotator ) {
return ((ConfigurationRotator)scm).getAcrs().getLastResults( project, null, number );
} else {
return null;
}
if (scm instanceof ConfigurationRotator) {
return ((ConfigurationRotator) scm).getAcrs().getLastResults(project, null, number);
} else {
return null;
}
}

public ConfigurationRotatorBuildAction getLastAction() {
SCM scm = project.getScm();
if (scm instanceof ConfigurationRotator) {
return ((ConfigurationRotator) scm).getAcrs().getLastResult(project, null);
} else {
return null;
}
}

public ConfigurationRotatorBuildAction getLastAction() {
SCM scm = project.getScm();
if( scm instanceof ConfigurationRotator ) {
return ((ConfigurationRotator)scm).getAcrs().getLastResult( project, null );
} else {
return null;
}
}

}

0 comments on commit 8e6412f

Please sign in to comment.