Skip to content

Commit

Permalink
[JENKINS-35188] Add warning when Project start by /
Browse files Browse the repository at this point in the history
  • Loading branch information
fbelzunc committed Jun 2, 2016
1 parent 348eec8 commit 9f96f15
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/hudson/plugins/batch_task/BatchTaskInvoker.java
Expand Up @@ -10,13 +10,15 @@
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;
Expand Down Expand Up @@ -139,6 +141,27 @@ public ListBoxModel doFillTaskItems(@QueryParameter String project, @AncestorInP
}
return r;
}

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();
}

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,9 @@
<div>
The <strong>Full project name</strong>

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

<p>
In Jenkins <strong>Full project name</strong> cannot start by "/"
</div>
@@ -0,0 +1,3 @@
<div>
List of tasks contained on the Project. Empty means there is not any task on the selected Project.
</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 /

0 comments on commit 9f96f15

Please sign in to comment.