Skip to content
Permalink
Browse files

Implemented JENKINS-28983

  • Loading branch information
MadsNielsen committed Aug 26, 2015
1 parent 14d38e2 commit 46d3b9289cede412f9520285b0d5a22d6a2281b3
Showing with 518 additions and 222 deletions.
  1. +1 −1 pom.xml
  2. +27 −19 src/main/java/net/praqma/jenkins/configrotator/AbstractConfiguration.java
  3. +1 −1 src/main/java/net/praqma/jenkins/configrotator/AbstractConfigurationComponent.java
  4. +28 −23 src/main/java/net/praqma/jenkins/configrotator/AbstractConfigurationRotatorSCM.java
  5. +2 −4 src/main/java/net/praqma/jenkins/configrotator/AbstractPostConfigurationRotator.java
  6. +5 −13 src/main/java/net/praqma/jenkins/configrotator/ConfigurationRotator.java
  7. +44 −28 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM.java
  8. +38 −14 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCMConfiguration.java
  9. +3 −14 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCMPostBuild.java
  10. +6 −0 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/DetermineProject.java
  11. +20 −7 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/NextBaseline.java
  12. +8 −5 ...ain/java/net/praqma/jenkins/configrotator/scm/contribute/ConfigRotatorClearCaseConverterImpl.java
  13. +3 −0 src/main/resources/net/praqma/jenkins/configrotator/AbstractConfigurationRotatorSCM/config.jelly
  14. +5 −5 src/main/resources/net/praqma/jenkins/configrotator/ConfigurationRotatorBuildAction/summary.jelly
  15. +4 −4 src/main/resources/net/praqma/jenkins/configrotator/ConfigurationRotatorProjectAction/index.jelly
  16. +4 −4 src/main/resources/net/praqma/jenkins/configrotator/ConfigurationRotatorProjectAction/jobMain.jelly
  17. +0 −2 src/main/resources/net/praqma/jenkins/configrotator/ConfigurationRotatorPublisher/jobMain.jelly
  18. +6 −0 src/main/resources/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM/config.jelly
  19. +3 −0 ...ain/resources/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM/help-contribute.html
  20. +8 −0 ...main/resources/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM/help-usenewest.html
  21. +24 −26 ...in/resources/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCMConfiguration/cr.jelly
  22. +5 −1 src/test/java/net/praqma/jenkins/configrotator/ProjectBuilder.java
  23. +55 −43 src/test/java/net/praqma/jenkins/configrotator/SystemValidator.java
  24. +102 −0 src/test/java/net/praqma/jenkins/configrotator/functional/scm/clearcase/JENKINS28983.java
  25. +1 −1 .../praqma/jenkins/configrotator/unit/scm/clearcase/{ClearCaseDTOTests.java → ClearCaseDTOTest.java}
  26. +61 −6 ...praqma/jenkins/configrotator/{functional → unit}/scm/clearcase/ClearCaseUCMConfigurationTest.java
  27. +54 −0 src/test/java/net/praqma/jenkins/configrotator/unit/scm/clearcase/CompatabilityContributorTest.java
  28. +0 −1 src/test/java/net/praqma/jenkins/configrotator/unit/test/MiscTest.java
@@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.509.4</version>
<version>1.532.3</version>
</parent>
<developers>
<developer>
@@ -1,8 +1,6 @@
package net.praqma.jenkins.configrotator;

import hudson.model.AbstractBuild;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogEntry;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -19,30 +17,32 @@ public String getView( Class<?> clazz ) {
return clazz.getName().replace( '.', '/' ).replace( '$', '/' ) + "/" + "cr.jelly";
}

public AbstractConfigurationComponent getChangedComponent() {
public List<AbstractConfigurationComponent> getChangedComponents() {
List<AbstractConfigurationComponent> changedComponents = new ArrayList<AbstractConfigurationComponent>();
for( AbstractConfigurationComponent configuration : this.getList() ) {
if( configuration.isChangedLast() ) {
return (AbstractConfigurationComponent) configuration;
changedComponents.add(configuration);
}
}
return null;
return changedComponents;
}

/**
* Gets the index of the changed component.
*
* @return the index of the changed component. If there is no changed component default return value is -1
*/
public int getChangedComponentIndex() {
int index = -1;

for( AbstractConfigurationComponent configuration : this.getList() ) {
public List<Integer> getChangedComponentIndecies() {
List<Integer> indicies = new ArrayList<Integer>();
List<? extends AbstractConfigurationComponent> l = this.getList();
for( AbstractConfigurationComponent configuration : l ) {
if( configuration.isChangedLast() ) {
index = getList().indexOf( configuration );
int i = l.indexOf( configuration );
indicies.add(i);
}
}

return index;
return indicies;
}

@Override
@@ -58,22 +58,30 @@ public String toString() {

public abstract String toHtml();

public String getDescription( AbstractBuild<?, ?> build ) {

public String getDescription( ConfigurationRotatorBuildAction action ) {
if( description == null ) {
ConfigurationRotator rotator = (ConfigurationRotator) build.getProject().getScm();
if( getChangedComponent() == null ) {
ConfigurationRotator rotator = (ConfigurationRotator) action.getBuild().getProject().getScm();
if( getChangedComponents().isEmpty() ) {
return "New Configuration - no changes yet";
} else {
ConfigurationRotatorBuildAction previous = rotator.getAcrs().getPreviousResult( build, null );

//return String.format( "Commit changed:<br/>%s<br/>%s", previous.getConfigurationWithOutCast().getList().get( getChangedComponentIndex() ).prettyPrint(), getChangedComponent().prettyPrint() );
return String.format( "%s<br/>%s", ((T)previous.getConfigurationWithOutCast().getList().get( getChangedComponentIndex() ) ).prettyPrint(), getChangedComponent().prettyPrint() );
ConfigurationRotatorBuildAction previous = rotator.getAcrs().getPreviousResult( action.getBuild(), null );
List<Integer> changes = getChangedComponentIndecies();
List<AbstractConfigurationComponent> changedComps = getChangedComponents();

StringBuilder builder = new StringBuilder();
for(Integer i : changes) {
String c = String.format( "%s<br/>%s%n", ((T)previous.getConfigurationWithOutCast().getList().get( i) ).prettyPrint(), changedComps.get(i).prettyPrint() );
builder.append(c);
}

return builder.toString();
}
}

return description;
}


public String basicHtml( StringBuilder builder, String ... titles ) {

@@ -73,7 +73,7 @@ public Entry getFeedEntry( AbstractBuild<?, ?> build, Date updated ) {
entry.author = new Person( "Jenkins config-rotator job: "
+ build.getParent().getDisplayName() + ", build: #" + build.getNumber() );

entry.content = configuration.getDescription( build );
entry.content = configuration.getDescription( action );
Html.Break br1 = new Html.Break();
Html.Anchor linkFeeds = new Html.Anchor( ConfigurationRotatorReport.FeedFrontpageUrl(), "Click here for a list of available feeds" );
Html.Break br2 = new Html.Break();
@@ -1,5 +1,4 @@
package net.praqma.jenkins.configrotator;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
@@ -22,14 +21,16 @@
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogParser;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorVersion;
import net.praqma.jenkins.configrotator.scm.contribute.ConfigRotatorCompatabilityConverter;
import org.kohsuke.stapler.DataBoundSetter;

public abstract class AbstractConfigurationRotatorSCM implements Describable<AbstractConfigurationRotatorSCM>, ExtensionPoint {

private static final Logger logger = Logger.getLogger(AbstractConfigurationRotatorSCM.class.getName());
protected AbstractConfiguration projectConfiguration;
private boolean useNewest = false;

/**
* Return the name of the type
* @return The name of the abstract configuration rotator SCM.
*/
public abstract String getName();

@@ -51,6 +52,21 @@ public AbstractConfiguration getConfiguration() {

public abstract AbstractConfigurationRotatorSCM.Poller getPoller(AbstractProject<?, ?> project, Launcher launcher, FilePath workspace, TaskListener listener);

/**
* @return the useNewest
*/
public boolean isUseNewest() {
return useNewest;
}

/**
* @param useNewest the useNewest to set
*/
@DataBoundSetter
public void setUseNewest(boolean useNewest) {
this.useNewest = useNewest;
}

/**
*
* @param <C>
@@ -286,6 +302,7 @@ public void write(List<ConfigRotatorChangeLogEntry> entries) {

/**
* All registered {@link AbstractConfigurationRotatorSCM}s.
* @return
*/
public static DescriptorExtensionList<AbstractConfigurationRotatorSCM, ConfigurationRotatorSCMDescriptor<AbstractConfigurationRotatorSCM>> all() {
return Jenkins.getInstance().<AbstractConfigurationRotatorSCM, ConfigurationRotatorSCMDescriptor<AbstractConfigurationRotatorSCM>>getDescriptorList(AbstractConfigurationRotatorSCM.class);
@@ -296,22 +313,16 @@ public void write(List<ConfigRotatorChangeLogEntry> entries) {
for (ConfigurationRotatorSCMDescriptor<?> d : all()) {
list.add(d);
}

return list;
}

public ConfigurationRotatorBuildAction getLastResult(AbstractProject<?, ?> project, Class<? extends AbstractConfigurationRotatorSCM> clazz) {

for (AbstractBuild<?, ?> b = getLastBuildToBeConsidered(project); b != null; b = b.getPreviousBuild()) {
ConfigurationRotatorBuildAction r = b.getAction(ConfigurationRotatorBuildAction.class);

if (r != null) {
if (r.isDetermined() && (clazz == null || r.getClazz().equals(clazz))) {
return r;
}
if (r != null && r.isDetermined() && (clazz == null || r.getClazz().equals(clazz)) ) {
return r;
}
}

return null;
}

@@ -320,32 +331,26 @@ public DiedBecauseAction getLastDieAction(AbstractProject<?, ?> project) {
}

public ConfigurationRotatorBuildAction getPreviousResult(AbstractBuild<?, ?> build, Class<? extends AbstractConfigurationRotatorSCM> clazz) {

for (AbstractBuild<?, ?> b = build.getPreviousBuild(); b != null; b = b.getPreviousBuild()) {
ConfigurationRotatorBuildAction r = b.getAction(ConfigurationRotatorBuildAction.class);

if (r != null) {
if (r.isDetermined() && (clazz == null || r.getClazz().equals(clazz))) {
return r;
}
if (r != null && r.isDetermined() && (clazz == null || r.getClazz().equals(clazz)) ) {
return r;
}
}

return null;
}

public ArrayList<ConfigurationRotatorBuildAction> getLastResults(AbstractProject<?, ?> project, Class<? extends AbstractConfigurationRotatorSCM> clazz, int limit) {
ArrayList<ConfigurationRotatorBuildAction> actions = new ArrayList<ConfigurationRotatorBuildAction>();
for (AbstractBuild<?, ?> b = getLastBuildToBeConsidered(project); b != null; b = b.getPreviousBuild()) {
ConfigurationRotatorBuildAction r = b.getAction(ConfigurationRotatorBuildAction.class);
if (r != null) {
if (r.isDetermined() && ((clazz == null || r.getClazz().equals(clazz)))) {
actions.add(r);
if (actions.size() >= limit) {
return actions;
}
if (r!= null && r.isDetermined() && (clazz == null || r.getClazz().equals(clazz))) {
actions.add(r);
if (actions.size() >= limit) {
return actions;
}
}

}
return actions;
}
@@ -13,10 +13,8 @@

public static boolean doit( FilePath workspace, TaskListener listener, ConfigurationRotatorBuildAction action ) {
for( AbstractPostConfigurationRotator l : all() ) {
if( l.tiedTo().equals( action.getClazz() ) ) {
if( !l.perform( workspace, listener, action ) ) {
return false;
}
if( l.tiedTo().equals( action.getClazz()) && !l.perform( workspace, listener, action ) ) {
return false;
}
}
return true;
@@ -43,9 +43,6 @@
COMPATIBLE,
INCOMPATIBLE,
FAILED,
/*
* The tests failed and was unable to determine compatibility
*/
UNDETERMINED
}

@@ -61,16 +58,10 @@
private static String VERSION = "Unresolved";

static {
try {
if( Jenkins.getInstance() != null ) {
FEED_PATH = new File( Jenkins.getInstance().getRootDir(), FEED_DIR );
VERSION = Jenkins.getInstance().getPlugin( "config-rotator" ).getWrapper().getVersion();
} else {

}
} catch ( Exception e ) {
/* No op */
}
if( Jenkins.getInstance() != null ) {
FEED_PATH = new File( Jenkins.getInstance().getRootDir(), FEED_DIR );
VERSION = Jenkins.getInstance().getPlugin( "config-rotator" ).getWrapper().getVersion();
}
}

public static File getFeedPath() {
@@ -249,6 +240,7 @@ protected PollingResult compareRemoteRevisionWith( AbstractProject<?, ?> project
try {
if( reconfigure ) {
logger.fine( "Reconfigured, build now!" );

out.println( LOGGERNAME + "Configuration from scratch, build now!" );
return PollingResult.BUILD_NOW;
} else if( lastAction == null) {

0 comments on commit 46d3b92

Please sign in to comment.
You can’t perform that action at this time.