Skip to content

Commit

Permalink
Merged JENKINS-25445
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNielsen committed Nov 5, 2014
2 parents 5d57e8f + 2dea6cb commit 9c52249
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 137 deletions.
3 changes: 1 addition & 2 deletions pom.xml
Expand Up @@ -9,7 +9,7 @@
<url>http://wiki.jenkins-ci.org/display/JENKINS/Pretested+Integration+Plugin</url>
<name>Pretested integration</name>
<artifactId>pretested-integration</artifactId>
<version>2.1.2-SNAPSHOT</version>
<version>2.1.3-SNAPSHOT</version>
<packaging>hpi</packaging>

<developers>
Expand Down Expand Up @@ -77,7 +77,6 @@

<build>
<plugins>

<!--
Allows integration tests to clean test environment before build fails
use 'mvn verify' to run integration tests to allow 'post-integration-test' phase
Expand Down
Expand Up @@ -39,31 +39,35 @@ public AbstractSCMBridge(IntegrationStrategy integrationStrategy) {
}

public String getBranch() {
return branch;
logger.entering("AbstractSCMBridge", "getBranch");// Generated code DONT TOUCH! Bookmark: 7b6f3ea69850ae74b80bcda629a49db3
logger.exiting("AbstractSCMBridge", "getBranch");// Generated code DONT TOUCH! Bookmark: 71ff2f36490cbfa5f2ad2fe00d1631a0
return branch;
}

public Descriptor<AbstractSCMBridge> getDescriptor() {
return (SCMBridgeDescriptor<?>) Jenkins.getInstance().getDescriptorOrDie(getClass());
return (SCMBridgeDescriptor<?>) Jenkins.getInstance().getDescriptorOrDie(getClass());
}

public static DescriptorExtensionList<AbstractSCMBridge, SCMBridgeDescriptor<AbstractSCMBridge>> all() {
return Jenkins.getInstance().<AbstractSCMBridge, SCMBridgeDescriptor<AbstractSCMBridge>>getDescriptorList(AbstractSCMBridge.class);
return Jenkins.getInstance().<AbstractSCMBridge, SCMBridgeDescriptor<AbstractSCMBridge>>getDescriptorList(AbstractSCMBridge.class);
}

public static List<SCMBridgeDescriptor<?>> getDescriptors() {
List<SCMBridgeDescriptor<?>> list = new ArrayList<SCMBridgeDescriptor<?>>();
public static List<SCMBridgeDescriptor<?>> getDescriptors() {
List<SCMBridgeDescriptor<?>> list = new ArrayList<SCMBridgeDescriptor<?>>();
for (SCMBridgeDescriptor<?> d : all()) {
list.add(d);
}
return list;
}
return list;
}

public static List<IntegrationStrategyDescriptor<?>> getBehaviours() {
List<IntegrationStrategyDescriptor<?>> list = new ArrayList<IntegrationStrategyDescriptor<?>>();
logger.entering("AbstractSCMBridge", "getBehaviours");// Generated code DONT TOUCH! Bookmark: 683867f2e0a65e8854a550f17520af17
List<IntegrationStrategyDescriptor<?>> list = new ArrayList<IntegrationStrategyDescriptor<?>>();
for(IntegrationStrategyDescriptor<?> descr : IntegrationStrategy.all()) {
list.add(descr);
}
return list;
logger.exiting("AbstractSCMBridge", "getBehaviours");// Generated code DONT TOUCH! Bookmark: ab82e2ca5b94ef8089d6c1509b2b6c3d
return list;
}


Expand All @@ -83,7 +87,9 @@ public static List<IntegrationStrategyDescriptor<?>> getBehaviours() {
* @throws NothingToDoException
*/
public void prepareWorkspace(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener, Commit<?> commit) throws EstablishWorkspaceException, NothingToDoException, IntegationFailedExeception {
mergeChanges(build, launcher, listener, commit);
logger.entering("AbstractSCMBridge", "prepareWorkspace", new Object[] { build, listener, launcher, commit });// Generated code DONT TOUCH! Bookmark: 153879db1346111ba452f21bdef681e3
mergeChanges(build, launcher, listener, commit);
logger.exiting("AbstractSCMBridge", "prepareWorkspace");// Generated code DONT TOUCH! Bookmark: c1434f914c8ce73e41e5ea7b7ea1029a
}

/**
Expand All @@ -96,7 +102,9 @@ public void prepareWorkspace(AbstractBuild<?, ?> build, Launcher launcher, Build
* @throws IntegationFailedExeception
*/
protected void mergeChanges(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener, Commit<?> commit) throws NothingToDoException, IntegationFailedExeception {
integrationStrategy.integrate(build, launcher, listener, this, commit);
logger.entering("AbstractSCMBridge", "mergeChanges", new Object[] { build, listener, launcher, commit });// Generated code DONT TOUCH! Bookmark: 2929a792ffc98c3546ea6e7755f81916
integrationStrategy.integrate(build, launcher, listener, this, commit);
logger.exiting("AbstractSCMBridge", "mergeChanges");// Generated code DONT TOUCH! Bookmark: a55866afd1caa8a8ab61b77dbbc2f130
}

/**
Expand Down Expand Up @@ -131,7 +139,9 @@ public boolean applySkipBehaviour(AbstractBuild<?,?> build, BuildListener listen
* @return
*/
protected Commit<?> determineIntegrationHead(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) {
return null;
logger.entering("AbstractSCMBridge", "determineIntegrationHead", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: 94e894e8dad5dfb0e85092e8e93ff296
logger.exiting("AbstractSCMBridge", "determineIntegrationHead");// Generated code DONT TOUCH! Bookmark: 19478dfa81d1cac69955a0cb6ee4ecdd
return null;
}

/**
Expand All @@ -147,23 +157,30 @@ protected Commit<?> determineIntegrationHead(AbstractBuild<?, ?> build, Launcher
* @throws NextCommitFailureException
*/
public Commit<?> nextCommit(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener, Commit<?> commit) throws NextCommitFailureException {
return null;
logger.entering("AbstractSCMBridge", "nextCommit", new Object[] { build, listener, launcher, commit });// Generated code DONT TOUCH! Bookmark: b28ff589e6d8f755b1062bf3d667b16d
logger.exiting("AbstractSCMBridge", "nextCommit");// Generated code DONT TOUCH! Bookmark: f0aa06678500b5cf31af6f72481f9561
return null;
}

public void commit(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws CommitChangesFailureException {
//nop
logger.entering("AbstractSCMBridge", "commit", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: 0858e763f8f80805e3caa7a6a8957226
logger.exiting("AbstractSCMBridge", "commit");// Generated code DONT TOUCH! Bookmark: 88b215c6f16b1aa5e6458f4686fef503
}

public void deleteIntegratedBranch(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws DeleteIntegratedBranchException {
//nop
logger.entering("AbstractSCMBridge", "deleteIntegratedBranch", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: a499b16a8f9e177b3cb5bb52f9db446b
logger.exiting("AbstractSCMBridge", "deleteIntegratedBranch");// Generated code DONT TOUCH! Bookmark: ec2017cf2a7526cfb7470217ea25413e
}

public void updateBuildDescription(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) {
//nop
logger.entering("AbstractSCMBridge", "updateBuildDescription", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: c0623c03e84a75c85d9db68bb8078a54
logger.exiting("AbstractSCMBridge", "updateBuildDescription");// Generated code DONT TOUCH! Bookmark: 832f1d788154dbccfc795d2762c455ca
}

public Result getRequiredResult() {
return Result.SUCCESS;
logger.entering("AbstractSCMBridge", "getRequiredResult");// Generated code DONT TOUCH! Bookmark: f015d31908905293b47ac7cd98635eb8
logger.exiting("AbstractSCMBridge", "getRequiredResult");// Generated code DONT TOUCH! Bookmark: e5202ad86a308a7620940ca0487810ef
return Result.SUCCESS;
}

/**
Expand All @@ -179,8 +196,30 @@ public Result getRequiredResult() {
*/
public abstract void handlePostBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException;

public void validateConfiguration(AbstractProject<?,?> project) throws UnsupportedConfigurationException {

public void validateConfiguration(AbstractProject<?,?> project) throws UnsupportedConfigurationException { }

public void handlePostBuild( AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws IOException {
logger.entering("AbstractSCMBridge", "handlePostBuild", new Object[] { build, listener, launcher });// Generated code DONT TOUCH! Bookmark: 9411c48462575da7c6477c5a34f7546d
Result result = build.getResult();
updateBuildDescription(build, launcher, listener);

// The purpose of this section of code is to disallow usage of the master branch as the polling branch.
BuildData gitBuildData = build.getAction(BuildData.class);
Branch gitDataBranch = gitBuildData.lastBuild.revision.getBranches().iterator().next();
String devBranchName = gitDataBranch.getName();
if (devBranchName.contains("master")) {
listener.getLogger().println(LOG_PREFIX + "Using the master branch for polling and development is not" +
" allowed since it will attempt to merge it to other branches and delete it after.");
build.setResult(Result.FAILURE);
}

if (result != null && result.isBetterOrEqualTo(getRequiredResult())) {
listener.getLogger().println(LOG_PREFIX + "Commiting changes");
commit(build, launcher, listener);
listener.getLogger().println(LOG_PREFIX + "Deleting development branch");
deleteIntegratedBranch(build, launcher, listener);
}
logger.exiting("AbstractSCMBridge", "handlePostBuild");// Generated code DONT TOUCH! Bookmark: d9d394d41d1eff3334403d5c957996b8
}

private static final Logger logger = Logger.getLogger(AbstractSCMBridge.class.getName());
Expand Down
@@ -1,8 +1,11 @@
package org.jenkinsci.plugins.pretestedintegration;

import java.util.concurrent.Semaphore;
import java.util.logging.Logger;

public final class BuildQueue {

private final static Logger logger = Logger.getLogger(BuildQueue.class.getName());// Generated code DONT TOUCH! Bookmark: 3ca61d8e671737b5ead8aaccd31875c4
private static BuildQueue instance;

Semaphore semaphore;
Expand All @@ -18,9 +21,11 @@ private BuildQueue() {
* Get the singleton instance.
*/
public static BuildQueue getInstance() {
logger.entering("BuildQueue", "getInstance");// Generated code DONT TOUCH! Bookmark: e85647720e74c86d6e3c473cc744be0d
if(instance == null) {
instance = new BuildQueue();
}
logger.exiting("BuildQueue", "getInstance");// Generated code DONT TOUCH! Bookmark: a8860d044f6d7209a50db4df3efc155e
return instance;
}

Expand All @@ -31,21 +36,27 @@ public static BuildQueue getInstance() {
* every error scenario releases the lock at some point.
*/
public void enqueueAndWait() {
logger.entering("BuildQueue", "enqueueAndWait");// Generated code DONT TOUCH! Bookmark: de958aca2d596894ae022627fa2c59f7
semaphore.acquireUninterruptibly();
logger.exiting("BuildQueue", "enqueueAndWait");// Generated code DONT TOUCH! Bookmark: 8d9b0ef93c509d9925807ba1d651884c
}

/**
* Signal that the build is done and a new one can get access.
*/
public void release() {
logger.entering("BuildQueue", "release");// Generated code DONT TOUCH! Bookmark: ab5b5d150b1249cfe2d92dc55e826a2f
semaphore.release();
logger.exiting("BuildQueue", "release");// Generated code DONT TOUCH! Bookmark: 5ba4d0199b4978dfb73accdbfd946aae
}

/**
* Test if the lock is available, without blocking.
* @return boolean indicating if the queue is not occupied
*/
public boolean available() {
logger.entering("BuildQueue", "available");// Generated code DONT TOUCH! Bookmark: a5770e885a1c3c79b9996916440b4c7a
logger.exiting("BuildQueue", "available");
return semaphore.availablePermits() > 0;
}
}
Expand Up @@ -16,10 +16,14 @@ public Commit(T commitId){
}

public T getId(){
logger.entering("Commit", "getId");// Generated code DONT TOUCH! Bookmark: 852679f6e176ac77f59b18a702f68d2a
logger.exiting("Commit", "getId");// Generated code DONT TOUCH! Bookmark: c09e520e8d2c040802722b0a25b6ec0a
return this.commitId;
}

public static ExtensionList<Commit> all() {
logger.entering("Commit", "all");// Generated code DONT TOUCH! Bookmark: deefc50556b39588e2e9a1ff76461db7
logger.exiting("Commit", "all");// Generated code DONT TOUCH! Bookmark: ee477ee51fae325cfdc03060546322b6
return Hudson.getInstance().getExtensionList(Commit.class);
}

Expand Down
Expand Up @@ -15,23 +15,28 @@
import hudson.model.BuildListener;
import hudson.model.Describable;
import hudson.model.Descriptor;
import java.util.logging.Logger;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;

public abstract class IntegrationStrategy implements Describable<IntegrationStrategy>, ExtensionPoint {
public abstract void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener, AbstractSCMBridge bridge, Commit<?> commit) throws IntegationFailedExeception, NothingToDoException;
private final static Logger logger = Logger.getLogger(IntegrationStrategy.class.getName());// Generated code DONT TOUCH! Bookmark: 3ca61d8e671737b5ead8aaccd31875c4

public abstract void integrate(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener, AbstractSCMBridge bridge, Commit<?> commit) throws IntegationFailedExeception, NothingToDoException;

@DataBoundConstructor
public IntegrationStrategy() { }



public Descriptor<IntegrationStrategy> getDescriptor() {
return (IntegrationStrategyDescriptor<?>)Jenkins.getInstance().getDescriptorOrDie(getClass());
logger.entering("IntegrationStrategy", "getDescriptor");// Generated code DONT TOUCH! Bookmark: 24cc4de9955cf69f2428d18f247547c0
logger.exiting("IntegrationStrategy", "getDescriptor");// Generated code DONT TOUCH! Bookmark: ecd722247263f21a17188169745720f1´
return (IntegrationStrategyDescriptor<?>)Jenkins.getInstance().getDescriptorOrDie(getClass());
}

public static DescriptorExtensionList<IntegrationStrategy,IntegrationStrategyDescriptor<IntegrationStrategy>> all() {
return Jenkins.getInstance().<IntegrationStrategy,IntegrationStrategyDescriptor<IntegrationStrategy>>getDescriptorList(IntegrationStrategy.class);
logger.entering("IntegrationStrategy", "all");// Generated code DONT TOUCH! Bookmark: b760438f7e1423732caaa9ef553c5f93
logger.exiting("IntegrationStrategy", "all");// Generated code DONT TOUCH! Bookmark: 4a32ea823412bf7eb75d28dd9edca807
return Jenkins.getInstance().<IntegrationStrategy,IntegrationStrategyDescriptor<IntegrationStrategy>>getDescriptorList(IntegrationStrategy.class);
}

}
Expand Up @@ -17,11 +17,11 @@
*/
public abstract class IntegrationStrategyDescriptor<T extends IntegrationStrategy> extends Descriptor<IntegrationStrategy> {

public abstract boolean isApplicable(Class<? extends AbstractSCMBridge> bridge);
public abstract boolean isApplicable(Class<? extends AbstractSCMBridge> bridge);

@Override
public IntegrationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
return req.bindJSON(IntegrationStrategy.class, formData);
return req.bindJSON(IntegrationStrategy.class, formData);
}

}
Expand Up @@ -32,22 +32,28 @@ public PretestedIntegrationAction(AbstractBuild<?, ?> build, Launcher launcher,
this.commit = scmBridge.nextCommit(build, launcher, listener, last);
}



public String getDisplayName() {
return null;
logger.entering("PretestedIntegrationAction", "getDisplayName");// Generated code DONT TOUCH! Bookmark: 3fb34e2a852b5aabe47573d3958d0bf0
logger.exiting("PretestedIntegrationAction", "getDisplayName");// Generated code DONT TOUCH! Bookmark: 152a7955fe370131e8203e4d8bfc6c24
return null;
}

public String getIconFileName() {
return null;
logger.entering("PretestedIntegrationAction", "getIconFileName");// Generated code DONT TOUCH! Bookmark: ca4d6f91bca42ec63e5f7623655ad110
logger.exiting("PretestedIntegrationAction", "getIconFileName");// Generated code DONT TOUCH! Bookmark: 7b30fa75160a837a01fcf455fdaa57c8
return null;
}

public String getUrlName() {
return "pretested-integration";
logger.entering("PretestedIntegrationAction", "getUrlName");// Generated code DONT TOUCH! Bookmark: cf7c72a753adf447c5674dbc81b3b1b7
logger.exiting("PretestedIntegrationAction", "getUrlName");// Generated code DONT TOUCH! Bookmark: a61b5775071f223c0c2dc704582be204
return "pretested-integration";
}

public Commit<?> getCommit() {
return this.commit;
logger.entering("PretestedIntegrationAction", "getCommit");// Generated code DONT TOUCH! Bookmark: b43ca3a0527679c146edbad0873f0122
logger.exiting("PretestedIntegrationAction", "getCommit");// Generated code DONT TOUCH! Bookmark: 674d4923ce7e049dffd9392fabc70101
return this.commit;
}

/**
Expand All @@ -63,13 +69,15 @@ public Commit<?> getCommit() {
* @throws EstablishWorkspaceException
*/
public boolean initialise(Launcher launcher, BuildListener listener) throws IntegationFailedExeception, NothingToDoException, EstablishWorkspaceException {
boolean result = false;
logger.entering("PretestedIntegrationAction", "initialise", new Object[] { listener, launcher });// Generated code DONT TOUCH! Bookmark: 243ef9e5f61005fcf1963a350f7abb77
boolean result = false;

if (commit != null) {
result = true;
scmBridge.prepareWorkspace(build, launcher, listener, commit);
}
return result;
logger.exiting("PretestedIntegrationAction", "initialise");// Generated code DONT TOUCH! Bookmark: 6f58d37470766bd11e40a451648336e5
return result;
}

/**
Expand All @@ -84,8 +92,10 @@ public boolean initialise(Launcher launcher, BuildListener listener) throws Inte
*/
public boolean finalise(Launcher launcher, BuildListener listener) throws IOException {
scmBridge.handlePostBuild(build, launcher, listener);
return true;
logger.entering("PretestedIntegrationAction", "finalise", new Object[] { listener, launcher });// Generated code DONT TOUCH! Bookmark: 23e6352a21c64c077dc4297b12d4daa6
scmBridge.handlePostBuild(build, launcher, listener);
logger.exiting("PretestedIntegrationAction", "finalise");// Generated code DONT TOUCH! Bookmark: e8f9ed6662703ed637d9ea56f8214d09
return true;
}

private static final Logger logger = Logger.getLogger(PretestedIntegrationAction.class.getName());
Expand All @@ -94,13 +104,17 @@ public boolean finalise(Launcher launcher, BuildListener listener) throws IOExce
* @return the currentIntegrationTip
*/
public Commit<?> getCurrentIntegrationTip() {
return currentIntegrationTip;
logger.entering("PretestedIntegrationAction", "getCurrentIntegrationTip");// Generated code DONT TOUCH! Bookmark: ffd3b899be05f13052473c38f95fa2d7
logger.exiting("PretestedIntegrationAction", "getCurrentIntegrationTip");// Generated code DONT TOUCH! Bookmark: 6cdb1c69a0b483325f5f54412d160b1f
return currentIntegrationTip;
}

/**
* @param currentIntegrationTip the currentIntegrationTip to set
*/
public void setCurrentIntegrationTip(Commit<?> currentIntegrationTip) {
this.currentIntegrationTip = currentIntegrationTip;
logger.entering("PretestedIntegrationAction", "setCurrentIntegrationTip", new Object[] { currentIntegrationTip });// Generated code DONT TOUCH! Bookmark: 7fe363971caf294085b34a533da2ceed
this.currentIntegrationTip = currentIntegrationTip;
logger.exiting("PretestedIntegrationAction", "setCurrentIntegrationTip");// Generated code DONT TOUCH! Bookmark: 6bd252060b7896da02bf44455dd4a422
}
}

0 comments on commit 9c52249

Please sign in to comment.