package org.jenkinsci.plugins.p4_client.review; import hudson.model.Action; import hudson.model.ParameterValue; import hudson.model.AbstractProject; import hudson.model.Cause; import hudson.model.CauseAction; import hudson.model.ParameterDefinition; import hudson.model.ParametersAction; import hudson.model.Queue; import hudson.model.StringParameterDefinition; import hudson.model.StringParameterValue; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; import javax.servlet.ServletException; import jenkins.model.Jenkins; import jenkins.util.TimeDuration; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; public class ReviewAction implements Action { private final AbstractProject<?, ?> project; public AbstractProject<?, ?> getProject() { return project; } public ReviewAction(AbstractProject<?, ?> project) { this.project = project; } public String getIconFileName() { return "/plugin/p4-client/icons/p4.png"; } public String getDisplayName() { return "Build Review"; } public String getUrlName() { return "review"; } /** * Jelly Method * * @return */ public List<StringParameterValue> getAvailableParameters() { List<StringParameterValue> stringParameters = new ArrayList<StringParameterValue>(); for (ParameterDefinition parameterDefinition : getParameterDefinitions()) { StringParameterValue stringParameter = new StringParameterValue( parameterDefinition.getName(), parameterDefinition.getDescription()); stringParameters.add(stringParameter); } return stringParameters; } public void doBuildSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { JSONObject formData = req.getSubmittedForm(); if (!formData.isEmpty()) { doBuild(req, rsp); } } public void doBuild(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { project.checkPermission(AbstractProject.BUILD); List<ParameterValue> values = new ArrayList<ParameterValue>(); List<ParameterDefinition> defs = getParameterDefinitions(); for (ParameterDefinition d : defs) { ParameterValue value = d.createValue(req); if (value != null) { values.add(value); } } // Schedule build TimeDuration delay = new TimeDuration(project.getQuietPeriod()); CauseAction cause = new CauseAction(new Cause.UserIdCause()); ParametersAction params = new ParametersAction(values); Queue queue = Jenkins.getInstance().getQueue(); queue.schedule(project, delay.getTime(), params, cause); // send the user back to the job top page. rsp.sendRedirect("../"); } private List<ParameterDefinition> getParameterDefinitions() { List<ParameterDefinition> swarm = new ArrayList<ParameterDefinition>(); swarm.add(new StringParameterDefinition("review", null)); swarm.add(new StringParameterDefinition("change", null)); swarm.add(new StringParameterDefinition("label", null)); swarm.add(new StringParameterDefinition("status", null)); swarm.add(new StringParameterDefinition("pass", null)); swarm.add(new StringParameterDefinition("fail", null)); return swarm; } final static Logger LOGGER = Logger.getLogger(ReviewAction.class.getName()); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9554 | gronk | mege in Paul's changes | ||
#1 | 8783 | gronk | Populate //guest/gronk/p4-jenkins/.... | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4_client/review/ReviewAction.java | |||||
#5 | 8737 | Paul Allen |
Added basic Help for SCM Configuration page. Tidy up descriptions and fix (null:null) in Credential summary. |
||
#4 | 8729 | Paul Allen |
Changed Build Review to Transient Action (so no check box required). - Added Perforce Icon to Build Review Action. |
||
#3 | 8693 | Paul Allen | Added manual launch Review page - POST from Jenkins. | ||
#2 | 8688 | Paul Allen | (Work in progress) Able to call build from review Action and pass URL params. | ||
#1 | 8683 | Paul Allen | Simple Action plugin hooks for building reviews in a Jenkins Job. |