Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-32525] Merged #2087.
  • Loading branch information
jglick committed Mar 17, 2016
2 parents f1d5653 + 85365c6 commit a4cabd5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion changelog.html
Expand Up @@ -58,14 +58,17 @@
<li class="bug">
Improve logging and error message when JNLP is already in use.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-33453">issue 33453</a>)
<li class="bug">
<code>NullPointerException</code> from <code>BuildTrigger$DescriptorImpl.doCheck</code> when using <em>Build other projects</em> in <em>Promotion process</em> of a CloudBees template, and perhaps other circumstances.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-32525">issue 32525</a>)
<li class="rfe">
Improved the Build Other Projects help message.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-32134">issue 32134</a>)
<li class="bug">
FutureImpl.cancel() doesn't cancel the linked job.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-33038">issue 33038</a>)
<li class="bug">
Reject marformed range syntax.
Reject malformed range syntax.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-33037">issue 33037</a>)
</ul>
</div><!--=TRUNK-END=-->
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/tasks/BuildTrigger.java
Expand Up @@ -367,6 +367,8 @@ public boolean showEvenIfUnstableOption(@CheckForNull Class<? extends AbstractPr
* Form validation method.
*/
public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) {
// JENKINS-32525: Check that it behaves gracefully for an unknown context
if (project == null) return FormValidation.ok(Messages.BuildTrigger_ok_ancestor_is_null());
// Require CONFIGURE permission on this project
if(!project.hasPermission(Item.CONFIGURE)) return FormValidation.ok();

Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/hudson/tasks/Messages.properties
Expand Up @@ -47,6 +47,7 @@ BuildTrigger.NoSuchProject=No such project \u2018{0}\u2019. Did you mean \u2018{
BuildTrigger.NoProjectSpecified=No project specified
BuildTrigger.NotBuildable={0} is not buildable
BuildTrigger.Triggering=Triggering a new build of {0}
BuildTrigger.ok_ancestor_is_null=Ancestor/Context Unknown: the project specified cannot be validated
BuildTrigger.warning_access_control_for_builds_in_glo=Warning: \u2018Access Control for Builds\u2019 in global security configuration is empty, so falling back to legacy behavior of permitting any downstream builds to be triggered
BuildTrigger.warning_this_build_has_no_associated_aut=Warning: this build has no associated authentication, so build permissions may be lacking, and downstream projects which cannot even be seen by an anonymous user will be silently skipped
BuildTrigger.warning_you_have_no_plugins_providing_ac=Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Expand Down
8 changes: 7 additions & 1 deletion test/src/test/java/hudson/tasks/BuildTriggerTest.java
Expand Up @@ -222,6 +222,7 @@ public void downstreamProjectSecurity() throws Exception {
assertEquals(Collections.singletonList(downstream), upstream.getDownstreamProjects());
// Downstream projects whose existence we are not aware of will silently not be triggered:
assertDoCheck(alice, Messages.BuildTrigger_NoSuchProject(downstreamName, "upstream"), upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
FreeStyleBuild b = j.buildAndAssertSuccess(upstream);
j.assertLogNotContains(downstreamName, b);
j.waitUntilNoActivity();
Expand All @@ -232,6 +233,7 @@ public void downstreamProjectSecurity() throws Exception {
AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty(grantedPermissions);
downstream.addProperty(amp);
assertDoCheck(alice, Messages.BuildTrigger_you_have_no_permission_to_build_(downstreamName), upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
j.assertLogContains(downstreamName, b);
j.waitUntilNoActivity();
Expand All @@ -242,6 +244,7 @@ public void downstreamProjectSecurity() throws Exception {
amp = new AuthorizationMatrixProperty(grantedPermissions);
downstream.addProperty(amp);
assertDoCheck(alice, null, upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
j.assertLogContains(downstreamName, b);
j.waitUntilNoActivity();
Expand All @@ -251,8 +254,9 @@ public void downstreamProjectSecurity() throws Exception {
assertNotNull(cause);
assertEquals(b, cause.getUpstreamRun());
// Now if we have configured some QIA’s but they are not active on this job, we should run as anonymous. Which would normally have no permissions:
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(Collections.<String,Authentication>emptyMap()));
QueueItemAuthenticatorConfiguration.get().getAuthenticators().replace(new MockQueueItemAuthenticator(Collections.<String, Authentication>emptyMap()));
assertDoCheck(alice, Messages.BuildTrigger_you_have_no_permission_to_build_(downstreamName), upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
j.assertLogNotContains(downstreamName, b);
j.assertLogContains(Messages.BuildTrigger_warning_this_build_has_no_associated_aut(), b);
Expand All @@ -265,6 +269,7 @@ public void downstreamProjectSecurity() throws Exception {
amp = new AuthorizationMatrixProperty(grantedPermissions);
downstream.addProperty(amp);
assertDoCheck(alice, null, upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
j.assertLogContains(downstreamName, b);
j.waitUntilNoActivity();
Expand All @@ -280,6 +285,7 @@ public void downstreamProjectSecurity() throws Exception {
downstream.addProperty(amp);
QueueItemAuthenticatorConfiguration.get().getAuthenticators().clear();
assertDoCheck(alice, Messages.BuildTrigger_NoSuchProject(downstreamName, "upstream"), upstream, downstreamName);
assertDoCheck(alice, null, null, downstreamName);
b = j.buildAndAssertSuccess(upstream);
j.assertLogContains(downstreamName, b);
j.assertLogContains(Messages.BuildTrigger_warning_access_control_for_builds_in_glo(), b);
Expand Down

0 comments on commit a4cabd5

Please sign in to comment.