Skip to content
Permalink
Browse files

Implemented JENKINS-27215

  • Loading branch information...
MadsNielsen committed Apr 13, 2015
1 parent e8cc376 commit 331a98f27795df30ffdf9674ff879230849bed3f
Showing with 564 additions and 25 deletions.
  1. +6 −0 pom.xml
  2. +7 −0 src/main/java/net/praqma/jenkins/configrotator/AbstractConfigurationRotatorSCM.java
  3. +1 −2 src/main/java/net/praqma/jenkins/configrotator/AbstractPostConfigurationRotator.java
  4. +29 −3 src/main/java/net/praqma/jenkins/configrotator/ConfigurationRotatorPublisher.java
  5. +31 −2 src/main/java/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM.java
  6. +148 −0 src/main/java/net/praqma/jenkins/configrotator/scm/contribute/ClearcaseUCMCompatability.java
  7. +20 −0 src/main/java/net/praqma/jenkins/configrotator/scm/contribute/CompatabilityCompatible.java
  8. +70 −0 src/main/java/net/praqma/jenkins/configrotator/scm/contribute/CompatabilityContributor.java
  9. +45 −0 ...ain/java/net/praqma/jenkins/configrotator/scm/contribute/ConfigRotatorClearCaseConverterImpl.java
  10. +19 −0 ...ain/java/net/praqma/jenkins/configrotator/scm/contribute/ConfigRotatorCompatabilityConverter.java
  11. +38 −0 src/main/java/net/praqma/jenkins/configrotator/scm/contribute/RemoteCompatabilityContributor.java
  12. +101 −0 ...va/net/praqma/jenkins/configrotator/scm/contribute/dto/ClearCaseUCMConfigurationComponentDTO.java
  13. +30 −0 src/main/java/net/praqma/jenkins/configrotator/scm/contribute/dto/ClearCaseUCMConfigurationDTO.java
  14. +8 −8 src/main/java/net/praqma/jenkins/configrotator/scm/git/Git.java
  15. +4 −10 src/main/resources/net/praqma/jenkins/configrotator/scm/clearcaseucm/ClearCaseUCM/config.jelly
  16. +7 −0 src/test/java/net/praqma/jenkins/configrotator/fake/FakeSCM.java
@@ -379,6 +379,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>external-data</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>net.praqma</groupId>
@@ -21,6 +21,7 @@
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogEntry;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogParser;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorVersion;
import net.praqma.jenkins.configrotator.scm.contribute.ConfigRotatorCompatabilityConverter;

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

@@ -31,6 +32,12 @@
* Return the name of the type
*/
public abstract String getName();

public abstract ConfigRotatorCompatabilityConverter getConverter();

public boolean isContribute() {
return false;
}

public void setConfiguration(AbstractConfiguration configuration) {
this.projectConfiguration = configuration;
@@ -18,8 +18,7 @@ public static boolean doit( FilePath workspace, TaskListener listener, Configura
return false;
}
}
}

}
return true;
}

@@ -23,10 +23,17 @@
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import java.util.logging.Level;
import jenkins.model.GlobalConfiguration;
import jenkins.model.Jenkins;
import net.praqma.jenkins.configrotator.scm.contribute.CompatabilityCompatible;
import net.praqma.jenkins.configrotator.scm.contribute.RemoteCompatabilityContributor;
import org.jenkinsci.plugins.externaldata.ExternalDataException;
import org.jenkinsci.plugins.externaldata.ExternalDataPlugin;

public class ConfigurationRotatorPublisher extends Notifier {

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

public ConfigurationRotatorPublisher() {
}
@@ -42,7 +49,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

/* This must be ConfigRotator job */
if (build.getProject().getScm() instanceof ConfigurationRotator) {

ConfigurationRotator scmConverted = (ConfigurationRotator)build.getProject().getScm();
ConfigurationRotatorBuildAction action = build.getAction(ConfigurationRotatorBuildAction.class);
if (action != null) {

@@ -51,11 +58,30 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
} else {
action.setResult(ResultType.INCOMPATIBLE);
}

/**
* If the database is installed try to store information
*/
if(Jenkins.getInstance().getPlugin("external-data") != null) {
if(scmConverted.getAcrs().isContribute()) {
try {
CompatabilityCompatible compatible = scmConverted.getAcrs().getConverter().convert(build.getAction(ConfigurationRotatorBuildAction.class));
listener.getLogger().println(ConfigurationRotator.LOGGERNAME + "Preparing to contribute data about compatability");
build.getWorkspace().act(new RemoteCompatabilityContributor(compatible, GlobalConfiguration.all().get(ExternalDataPlugin.class).getProvider(), listener));
} catch (ExternalDataException dataex) {
listener.getLogger().println(dataex.getMessage());
} catch (Exception ex) {
listener.getLogger().println("Unknown error. See logs for more detail");
logger.log(Level.WARNING, "Unknown error encountered while trying to add comptability data. Trace follows", ex);
}
}
}

out.println(ConfigurationRotator.LOGGERNAME + "Configuration is " + action.getResult());

return AbstractPostConfigurationRotator.doit(build.getWorkspace(), listener, action);


} else {
DiedBecauseAction da = build.getAction(DiedBecauseAction.class);
out.println(ConfigurationRotator.LOGGERNAME + "Action was null, unable to set compatibility of configuration");
@@ -25,6 +25,8 @@
import net.praqma.jenkins.configrotator.*;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogEntry;
import net.praqma.jenkins.configrotator.scm.ConfigRotatorChangeLogParser;
import net.praqma.jenkins.configrotator.scm.contribute.ConfigRotatorClearCaseConverterImpl;
import net.praqma.jenkins.configrotator.scm.contribute.ConfigRotatorCompatabilityConverter;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -33,17 +35,24 @@
public class ClearCaseUCM extends AbstractConfigurationRotatorSCM implements Serializable {

private static final Logger logger = Logger.getLogger( ClearCaseUCM.class.getName() );
public List<ClearCaseUCMTarget> targets;

public List<ClearCaseUCMTarget> targets;

private PVob pvob;
private boolean contribute = false;

public ClearCaseUCM( PVob pvob ) {
this.pvob = pvob;
}

public ClearCaseUCM( String pvobName ) {
pvob = new PVob( pvobName );
}

@DataBoundConstructor
public ClearCaseUCM( String pvobName ) {
public ClearCaseUCM( String pvobName, boolean contribute ) {
pvob = new PVob( pvobName );
this.contribute = contribute;
}

public String getPvobName() {
@@ -121,6 +130,26 @@ public Poller getPoller( AbstractProject<?, ?> project, Launcher launcher, FileP
return new UCMPerformer(build, launcher, workspace, listener);
}

@Override
public ConfigRotatorCompatabilityConverter getConverter() {
return new ConfigRotatorClearCaseConverterImpl();
}

/**
* @return the contribute
*/
@Override
public boolean isContribute() {
return contribute;
}

/**
* @param contribute the contribute to set
*/
public void setContribute(boolean contribute) {
this.contribute = contribute;
}

public class UCMPerformer extends Performer<ClearCaseUCMConfiguration> {

public UCMPerformer( AbstractBuild<?, ?> build, Launcher launcher, FilePath workspace, BuildListener listener ) {
@@ -0,0 +1,148 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.praqma.jenkins.configrotator.scm.contribute;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import net.praqma.jenkins.configrotator.scm.contribute.dto.ClearCaseUCMConfigurationDTO;
import org.mongojack.ObjectId;

/**
*
* @author Mads
*/
public class ClearcaseUCMCompatability implements CompatabilityCompatible {

private String id;

private String jobName;
private Date registrationDate;
private int schemaRevision = 1;

public final String schemaType = "ccucm";
private boolean compatible;

/**
* The current configuration. And the components(s) that was flipped on run
*/
private ClearCaseUCMConfigurationDTO component;
private ClearCaseUCMConfigurationDTO configuration;

public ClearcaseUCMCompatability() { }

public ClearcaseUCMCompatability(ClearCaseUCMConfigurationDTO component, Date registrationDate, String jobName, boolean compatible, ClearCaseUCMConfigurationDTO configuration) {
this.registrationDate = registrationDate;
this.jobName = jobName;
this.compatible = compatible;
this.configuration = configuration;
this.component = component;
}

@ObjectId
@JsonProperty("_id")
public String getId() {
return id;
}

@ObjectId
@JsonProperty("_id")
public void setId(String id) {
this.id = id;
}

/**
* @return the jobName
*/
public String getJobName() {
return jobName;
}

/**
* @param jobName the jobName to set
*/
public void setJobName(String jobName) {
this.jobName = jobName;
}

/**
* @return the version
*/
public ClearCaseUCMConfigurationDTO getComponent() {
return component;
}

/**
* @param component the version to set
*/
public void setComponent(ClearCaseUCMConfigurationDTO component) {
this.component = component;
}

/**
* @return the compatible
*/
public boolean isCompatible() {
return compatible;
}

/**
* @param compatible the compatible to set
*/
public void setCompatible(boolean compatible) {
this.compatible = compatible;
}

/**
* @return the schemaId
*/
public int getSchemaRevision() {
return schemaRevision;
}

/**
* @param schemaRevision the schemaId to set
*/
public void setSchemaRevision(int schemaRevision) {
this.schemaRevision = schemaRevision;
}

/**
* @return the configuration
*/
public ClearCaseUCMConfigurationDTO getConfiguration() {
return configuration;
}

/**
* @param configuration the configuration to set
*/
public void setConfiguration(ClearCaseUCMConfigurationDTO configuration) {
this.configuration = configuration;
}

/**
* @return the schemaType
*/
public String getSchemaType() {
return schemaType;
}

@Override
public String toString() {
return id;
}

@Override
public Date getRegistrationDate() {
return registrationDate;
}

@Override
public void setRegistrationDate(Date registrationDate) {
this.registrationDate = registrationDate;
}

}
@@ -0,0 +1,20 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.praqma.jenkins.configrotator.scm.contribute;

import java.io.Serializable;
import java.util.Date;

/**
*
* Simple marker interface that tells that the class is meant to be stored in our compatability database
*
* @author Mads
*/
public interface CompatabilityCompatible extends Serializable {
public Date getRegistrationDate();
public void setRegistrationDate(Date registrationDate);
}

0 comments on commit 331a98f

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