package org.jenkinsci.plugins.p4.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/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 | |
---|---|---|---|---|---|
#17 | 29673 | Sandeep Kumar |
Merge pull request #188 from jenkinsci/CodeRefactoring Code Cleanup |
||
#16 | 28806 | Paul Allen |
Merge pull request #144 from VirtualTim/patch-1 Change `status` to be a choice instead of a string |
||
#15 | 26673 | Paul Allen |
Code cleanup - remove calls to Deprecated methods - Deprecated classes like AbstractStepImpl, AbstractStepDescriptorImpl and AbstractSynchronousStepExecution for P4TaggingStep |
||
#14 | 26352 | Paul Allen | [SECURITY-1765] | ||
#13 | 24622 | Paul Allen | Added 'command-launcher' for Jenkins 2.89.1 release and greater. | ||
#12 | 24529 | Paul Allen |
Swarm Commit Event support, refactoring and test. JENKINS-52605 (Fix doc in 'Includes' help bubble for MultiBranch) JENKINS-52066 (Improve Swarm Commit and Branch Event support) |
||
#11 | 22166 | Paul Allen | Brand update. | ||
#10 | 20902 | Paul Allen |
Enable Swarm builds on pipeline. JENKINS-38233 |
||
#9 | 20179 | Paul Allen | Javadoc fixes for java 8 builds. | ||
#8 | 19633 | Paul Allen |
Merge pull request #25 from amuniz/JENKINS-35210 Fix for SECURITY-170 |
||
#7 | 19593 | Paul Allen | More minor fixes to satisfy FindBugs Analysis. | ||
#6 | 19581 | Paul Allen | Minor fixes to satisfy FindBugs Analysis. | ||
#5 | 11492 | Paul Allen | Minor Fix: first parent builds and label namespace | ||
#4 | 10755 | Paul Allen |
Separate name space for 'label' parameter. Perforce Review endpoint added `label`, `change`, `status`, `pass`, and `fail` parameter into the environment, which is a shared name space. This clashed with the default `label` matrix name and causing users issues. The change prefixes the review parameters with `p4.` on addition to the environment. |
||
#3 | 9702 | Paul Allen |
Fix for null/empty params on Build Review. Includes processing of custom (non Swarm) params. |
||
#2 | 9695 | Paul Allen | Merge: Moved reference for icon to /plugin/p4/ | ||
#1 | 9690 | Paul Allen |
[Branching using p4-jenkins] Release 1.0.1 |
||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4/review/ReviewAction.java | |||||
#1 | 9672 | Paul Allen | Refactor name from 'p4_client' to 'p4'. | ||
//guest/paul_allen/dev/p4-jenkins/p4-client/src/main/java/org/jenkinsci/plugins/p4_client/review/ReviewAction.java | |||||
#8 | 9055 | Paul Allen |
Label support. Build at a label using the pram 'label'. This includes adding the label to the ChangeEntry, building the change reports and Browser links to Swarm. (TPI-102) |
||
#7 | 8971 | Paul Allen |
Attempt to fix rootUrl bug, but ended up tidying code. Turns out that you MUST set the Jenkins URL and click Save; even though the box has a default value it is not applied unless the configuration page is Applied/Saved. Manage Jenkins --> Configuration --> Jenkins Location: Jenkins URL |
||
#6 | 8923 | Paul Allen | Remove unused parameters 'project' and 'branch' that might be the cause of TPI-81. | ||
#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. |