Skip to content

Commit

Permalink
Merge pull request #3 from fbelzunc/JENKINS-35188
Browse files Browse the repository at this point in the history
[FIXED JENKINS-35410] Improve User Experience
  • Loading branch information
fbelzunc committed Jun 7, 2016
2 parents 70c492a + 76be8f7 commit 25303f8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/hudson/plugins/batch_task/BatchTaskInvoker.java
Expand Up @@ -10,16 +10,20 @@
import hudson.model.Cause.UpstreamCause;
import hudson.model.CauseAction;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.ItemGroup;
import hudson.model.Result;
import hudson.model.Run;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Notifier;
import hudson.tasks.Publisher;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
Expand Down Expand Up @@ -139,6 +143,29 @@ public ListBoxModel doFillTaskItems(@QueryParameter String project, @AncestorInP
}
return r;
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckProject(@QueryParameter String project) {
if (project.startsWith("/")) {
return FormValidation.warning(Messages.BatchTaskInvoker_ForwardSlash());
}
Jenkins jenkins = Jenkins.getInstance();
if (jenkins != null) {
Item item = jenkins.getItemByFullName(project);
if (item == null) {
return FormValidation.warning(Messages.BatchTaskInvoker_NoSuchProject(project));
}
}
return FormValidation.ok();
}

@Restricted(NoExternalUse.class)
public FormValidation doCheckTask(@QueryParameter String project, @QueryParameter String task) {
if (!project.isEmpty() && task.isEmpty()) {
return FormValidation.warning(Messages.BatchTaskInvoker_NoBatchTaskExists(task));
}
return FormValidation.ok();
}
}
}

Expand Down
@@ -0,0 +1,11 @@
<div>
The <strong>Full project name</strong>

<p>
For jobs inside a folder it is always a path like <strong>foo/bar</strong>
</p>

<p>
In Jenkins <strong>Full project name</strong> cannot start by "/"
</p>
</div>
@@ -0,0 +1,7 @@
<div>
List of tasks contained on the Project.

<p>
Empty means there is not any task on the selected Project.
</p>
</div>
Expand Up @@ -6,3 +6,4 @@ BatchTaskInvoker.NoSuchProject=No such project exists: {0}
BatchTaskInvoker.NoSuchTask=No such task exists: {0}. Perhaps you meant {1}
BatchTaskAction.DisplayName={0,choice,1#Task|1<Tasks}
BatchRunAction.DisplayName=Executed Tasks
BatchTaskInvoker.ForwardSlash=Project should be a Full Project Name which cannot start by /. Current settings may lead to the undefined behavior.

0 comments on commit 25303f8

Please sign in to comment.