|
15 | 15 | import hudson.model.AbstractProject; |
16 | 16 | import hudson.model.Action; |
17 | 17 | import hudson.model.Fingerprint; |
| 18 | +import hudson.model.Item; |
18 | 19 | import hudson.model.Result; |
19 | 20 | import hudson.model.Run; |
20 | 21 | import hudson.model.TaskListener; |
|
34 | 35 | import net.sf.json.JSONObject; |
35 | 36 | import org.apache.commons.lang.StringUtils; |
36 | 37 | import org.jenkinsci.Symbol; |
| 38 | +import org.kohsuke.stapler.AncestorInPath; |
37 | 39 | import org.kohsuke.stapler.DataBoundConstructor; |
38 | 40 | import org.kohsuke.stapler.QueryParameter; |
39 | 41 | import org.kohsuke.stapler.StaplerRequest; |
40 | | -import org.kohsuke.stapler.StaplerResponse; |
41 | 42 | import org.kohsuke.stapler.interceptor.RequirePOST; |
42 | 43 |
|
43 | 44 | import javax.annotation.Nonnull; |
@@ -466,8 +467,16 @@ public boolean configure(StaplerRequest req, JSONObject json) { |
466 | 467 | } |
467 | 468 |
|
468 | 469 | @SuppressWarnings("unused") |
469 | | - public ListBoxModel doFillProfileNameItems() { |
| 470 | + public ListBoxModel doFillProfileNameItems(@AncestorInPath Item item) { |
470 | 471 | final ListBoxModel model = new ListBoxModel(); |
| 472 | + if (item != null && !item.hasPermission(Item.CONFIGURE)) { |
| 473 | + return model; |
| 474 | + } |
| 475 | + if (item == null && !Jenkins.get().hasPermission(Item.CREATE)) { |
| 476 | + // accessing from $JENKINS_URL/pipeline-syntax |
| 477 | + return model; |
| 478 | + } |
| 479 | + |
471 | 480 | for (S3Profile profile : profiles) { |
472 | 481 | model.add(profile.getName(), profile.getName()); |
473 | 482 | } |
|
0 commit comments