Skip to content
Permalink
Browse files

Updated to use released plugin for database plugin. JENKINS-27215

  • Loading branch information...
MadsNielsen committed Jun 23, 2015
1 parent 331a98f commit 7efdad1afc20cd6fc1557f795d3c86c30e5580e7
@@ -382,8 +382,8 @@

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

<dependency>
@@ -28,8 +28,8 @@
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;
import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataException;
import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataPlugin;

public class ConfigurationRotatorPublisher extends Notifier {

@@ -62,13 +62,13 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
/**
* If the database is installed try to store information
*/
if(Jenkins.getInstance().getPlugin("external-data") != null) {
if(Jenkins.getInstance().getPlugin("compatibility-action-storage") != 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) {
build.getWorkspace().act(new RemoteCompatabilityContributor(compatible, GlobalConfiguration.all().get(CompatibilityDataPlugin.class).getProvider(), listener));
} catch (CompatibilityDataException dataex) {
listener.getLogger().println(dataex.getMessage());
} catch (Exception ex) {
listener.getLogger().println("Unknown error. See logs for more detail");
@@ -10,15 +10,15 @@
import java.util.logging.Logger;
import jenkins.model.GlobalConfiguration;
import net.praqma.jenkins.configrotator.ConfigurationRotatorBuildAction;
import org.jenkinsci.plugins.externaldata.MongoProviderImpl;
import org.jenkinsci.plugins.externaldata.ExternalDataException;
import org.jenkinsci.plugins.externaldata.ExternalDataPlugin;
import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataException;
import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataPlugin;
import org.jenkinsci.plugins.compatibilityaction.MongoProviderImpl;

/**
*
* @author Mads
*/
public class CompatabilityContributor implements Callable<Boolean, ExternalDataException> {
public class CompatabilityContributor implements Callable<Boolean, CompatibilityDataException> {

private static final Logger LOG = Logger.getLogger(CompatabilityContributor.class.getName());
private TaskListener listener;
@@ -34,15 +34,15 @@ public CompatabilityContributor(TaskListener listener, ConfigurationRotatorBuild
}

@Override
public Boolean call() throws ExternalDataException {
public Boolean call() throws CompatibilityDataException {
if(action != null) {
//Only add if the action is not 'Nothing to do' (grey)
if(action.isCompatible() && converter != null) {
CompatabilityCompatible compatabilityCompatible = converter.convert(action);

if(GlobalConfiguration.all().get(ExternalDataPlugin.class).getProvider() instanceof MongoProviderImpl) {
if(GlobalConfiguration.all().get(CompatibilityDataPlugin.class).getProvider() instanceof MongoProviderImpl) {
LOG.finest("Global configuration present, adding data to MongoDB");
MongoProviderImpl impl = ((MongoProviderImpl)GlobalConfiguration.all().get(ExternalDataPlugin.class).getProvider());
MongoProviderImpl impl = ((MongoProviderImpl)GlobalConfiguration.all().get(CompatibilityDataPlugin.class).getProvider());
impl.create(compatabilityCompatible);
LOG.finest(String.format("Done adding compatability information. Added compatability %s", compatabilityCompatible) );
}
@@ -8,27 +8,26 @@
import hudson.model.TaskListener;
import hudson.remoting.Callable;
import net.praqma.jenkins.configrotator.ConfigurationRotator;
import org.jenkinsci.plugins.externaldata.ExternalDataException;
import org.jenkinsci.plugins.externaldata.ExternalDataProvider;

import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataException;
import org.jenkinsci.plugins.compatibilityaction.CompatibilityDataProvider;
/**
*
* @author Mads
*/
public class RemoteCompatabilityContributor implements Callable<Boolean, ExternalDataException> {
public class RemoteCompatabilityContributor implements Callable<Boolean, CompatibilityDataException> {

public final CompatabilityCompatible item;
public final ExternalDataProvider provider;
public final CompatibilityDataProvider provider;
public final TaskListener listener;

public RemoteCompatabilityContributor(CompatabilityCompatible item, ExternalDataProvider provider, TaskListener listner) {
public RemoteCompatabilityContributor(CompatabilityCompatible item, CompatibilityDataProvider provider, TaskListener listner) {
this.item = item;
this.provider = provider;
this.listener = listner;
}

@Override
public Boolean call() throws ExternalDataException {
public Boolean call() throws CompatibilityDataException {
listener.getLogger().println(ConfigurationRotator.LOGGERNAME+provider);
provider.create(item, listener);
listener.getLogger().println(ConfigurationRotator.LOGGERNAME+"Done writing compatability object to database");

0 comments on commit 7efdad1

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