Skip to content

Commit

Permalink
Merge branch 'JENKINS-10930-bulk-polling'
Browse files Browse the repository at this point in the history
  • Loading branch information
swestcott committed Nov 13, 2011
2 parents d56b733 + 6568330 commit a89e3dd
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 257 deletions.
Expand Up @@ -37,6 +37,7 @@

import javax.servlet.ServletException;

import org.jvnet.hudson.plugins.bulkbuilder.model.BuildAction;
import org.jvnet.hudson.plugins.bulkbuilder.model.BuildHistory;
import org.jvnet.hudson.plugins.bulkbuilder.model.BuildHistoryItem;
import org.jvnet.hudson.plugins.bulkbuilder.model.BuildType;
Expand Down Expand Up @@ -76,62 +77,73 @@ public final void doBuild(StaplerRequest req, StaplerResponse rsp)
LOGGER.log(Level.FINE, "doBuild action called");
}

String buildAction = req.getParameter("action");
if (buildAction == null) {
rsp.forwardToPreviousPage(req);
return;
}

String buildType = req.getParameter("build");
if (buildType == null) {
rsp.forwardToPreviousPage(req);
return;
}

BuildAction action = BuildAction.valueOf(buildAction.toUpperCase());
BuildType type = BuildType.valueOf(buildType.toUpperCase());
String params = req.getParameter("params");

BulkParamProcessor processor = new BulkParamProcessor(params);
Builder builder = new Builder(processor.getProjectParams());
// TODO
String params = req.getParameter("params");
BulkParamProcessor processor = new BulkParamProcessor(params);

Builder builder = new Builder(action);

String pattern = req.getParameter("pattern");
if (pattern != null && !pattern.isEmpty()) {
builder.setPattern(pattern);
BuildHistory history = Hudson.getInstance().getPlugin(
BuildHistory.class);
history.add(new BuildHistoryItem(pattern));
}

String view = req.getParameter("view");
if (view != null && !view.isEmpty()) {
builder.setView(view);
}

switch (type) {
case ABORTED:
builder.buildAborted();
break;
case ALL:
builder.buildAll();
break;
case BYVIEW:
String viewName = req.getParameter("byview");
builder.buildView(viewName);
break;
case FAILED:
builder.buildFailed();
break;
case FAILED_ONLY:
builder.buildFailedOnly();
break;
case NOT_BUILD_ONLY:
builder.buildNotBuildOnly();
break;
case NOT_BUILT:
builder.buildNotBuilt();
break;
case PATTERN:
String pattern = req.getParameter("pattern");
builder.buildPattern(pattern);
BuildHistory history = Hudson.getInstance().getPlugin(
BuildHistory.class);
history.add(new BuildHistoryItem(pattern));
break;
case UNSTABLE:
builder.buildUnstable();
break;
case UNSTABLE_ONLY:
builder.buildUnstableOnly();
break;
case ABORTED:
builder.buildAborted();
break;
case ALL:
builder.buildAll();
break;
case FAILED:
builder.buildFailed();
break;
case FAILED_ONLY:
builder.buildFailedOnly();
break;
case NOT_BUILD_ONLY:
builder.buildNotBuildOnly();
break;
case NOT_BUILT:
builder.buildNotBuilt();
break;
case UNSTABLE:
builder.buildUnstable();
break;
case UNSTABLE_ONLY:
builder.buildUnstableOnly();
break;
}

rsp.forwardToPreviousPage(req);
}

/**
* Gets the number projects in the build queue
*
*
* @return
*/
@Exported
Expand All @@ -141,7 +153,7 @@ public final int getQueueSize() {

/**
* Gets the build pattern history
*
*
* @return
*/
@Exported
Expand All @@ -151,7 +163,7 @@ public final List<BuildHistoryItem> getHistory() {

/**
* Get all available {@link hudson.model.View} for drop down box.
*
*
* @return the views
*/
public final Collection<View> getViews() {
Expand Down
@@ -0,0 +1,36 @@
/*
* The MIT License
*
* Copyright (c) 2010-2011 Simon Westcott
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jvnet.hudson.plugins.bulkbuilder.model;

/**
* @author simon
*/
public enum BuildAction {

IMMEDIATE_BUILD,

POLL_SCM,

}

0 comments on commit a89e3dd

Please sign in to comment.