Skip to content

Commit a5b009e

Browse files
author
henry
committed
Merge branch 'master' into keymux-master
2 parents 576fa78 + 4e86ed4 commit a5b009e

File tree

6 files changed

+59
-10
lines changed

6 files changed

+59
-10
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
### Updates
22

3-
* Feature: Enable commentFilePath in the DSL (#514)
3+
### -> 1.41.0
4+
5+
* Fix for stale ghprbCommentBody values ([#504][#504])
6+
* Improve "Build triggered/started" messages ([#607][#607])
7+
* Avoid posting a comment for empty comment files ([#662][#662])
8+
* Use ssl validation for webhook ([#663][#663])
9+
10+
[#504]: https://github.com/jenkinsci/ghprb-plugin/pull/504
11+
[#607]: https://github.com/jenkinsci/ghprb-plugin/pull/607
12+
[#662]: https://github.com/jenkinsci/ghprb-plugin/pull/662
13+
[#663]: https://github.com/jenkinsci/ghprb-plugin/pull/663
414

515
#### -> 1.40.0
616

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<artifactId>ghprb</artifactId>
1313
<name>GitHub Pull Request Builder</name>
14-
<version>1.41.0-SNAPSHOT</version>
14+
<version>1.42.1-SNAPSHOT</version>
1515
<packaging>hpi</packaging>
1616

1717
<url>https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin</url>

src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHubAuth.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import hudson.util.FormValidation;
1919
import hudson.util.ListBoxModel;
2020
import hudson.util.Secret;
21+
import jenkins.model.Jenkins;
2122
import org.apache.commons.codec.binary.Hex;
2223
import org.apache.commons.lang.StringUtils;
2324
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
@@ -32,11 +33,11 @@
3233
import org.kohsuke.stapler.DataBoundConstructor;
3334
import org.kohsuke.stapler.QueryParameter;
3435
import org.kohsuke.stapler.export.Exported;
36+
import org.kohsuke.stapler.verb.POST;
3537

3638
import javax.crypto.Mac;
3739
import javax.crypto.spec.SecretKeySpec;
3840
import java.io.IOException;
39-
import java.net.URISyntaxException;
4041
import java.nio.charset.Charset;
4142
import java.util.ArrayList;
4243
import java.util.Arrays;
@@ -57,7 +58,7 @@ public class GhprbGitHubAuth extends AbstractDescribableImpl<GhprbGitHubAuth> {
5758

5859
private static final int SHA1_PREFIX_LENGTH = 5;
5960

60-
static final int INITIAL_CAPACITY = 3;
61+
private static final int INITIAL_CAPACITY = 3;
6162

6263
private final String serverAPIUrl;
6364

@@ -241,16 +242,15 @@ public String getDisplayName() {
241242
* @param serverAPIUrl the github api server url.
242243
* @param credentialsId the credentialsId from the credentials plugin
243244
* @return list box model.
244-
* @throws URISyntaxException If the url is bad
245245
*/
246246
public ListBoxModel doFillCredentialsIdItems(
247247
@AncestorInPath Item context,
248248
@QueryParameter String serverAPIUrl,
249249
@QueryParameter String credentialsId
250-
) throws URISyntaxException {
250+
) {
251251
List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(serverAPIUrl).build();
252252

253-
List<CredentialsMatcher> matchers = new ArrayList<CredentialsMatcher>(INITIAL_CAPACITY);
253+
List<CredentialsMatcher> matchers = new ArrayList<>(INITIAL_CAPACITY);
254254
if (!StringUtils.isEmpty(credentialsId)) {
255255
matchers.add(0, CredentialsMatchers.withId(credentialsId));
256256
}
@@ -273,14 +273,16 @@ public ListBoxModel doFillCredentialsIdItems(
273273
);
274274
}
275275

276-
276+
@POST
277277
public FormValidation doCreateApiToken(
278278
@QueryParameter("serverAPIUrl") final String serverAPIUrl,
279279
@QueryParameter("credentialsId") final String credentialsId,
280280
@QueryParameter("username") final String username,
281281
@QueryParameter("password") final String password) {
282282
try {
283283

284+
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
285+
284286
GitHubBuilder builder = new GitHubBuilder()
285287
.withEndpoint(serverAPIUrl)
286288
.withConnector(new HttpConnectorWithJenkinsProxy());
@@ -326,10 +328,14 @@ public FormValidation doCheckServerAPIUrl(@QueryParameter String value) {
326328
return FormValidation.warning("GitHub API URI is \"https://api.github.com\". GitHub Enterprise API URL ends with \"/api/v3\"");
327329
}
328330

331+
@POST
329332
public FormValidation doCheckRepoAccess(
330333
@QueryParameter("serverAPIUrl") final String serverAPIUrl,
331334
@QueryParameter("credentialsId") final String credentialsId,
332335
@QueryParameter("repo") final String repo) {
336+
337+
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
338+
333339
try {
334340
GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId);
335341
if (builder == null) {
@@ -339,7 +345,7 @@ public FormValidation doCheckRepoAccess(
339345
GHRepository repository = gh.getRepository(repo);
340346
StringBuilder sb = new StringBuilder();
341347
sb.append("User has access to: ");
342-
List<String> permissions = new ArrayList<String>(INITIAL_CAPACITY);
348+
List<String> permissions = new ArrayList<>(INITIAL_CAPACITY);
343349
if (repository.hasAdminAccess()) {
344350
permissions.add("Admin");
345351
}
@@ -357,9 +363,13 @@ public FormValidation doCheckRepoAccess(
357363
}
358364
}
359365

366+
@POST
360367
public FormValidation doTestGithubAccess(
361368
@QueryParameter("serverAPIUrl") final String serverAPIUrl,
362369
@QueryParameter("credentialsId") final String credentialsId) {
370+
371+
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
372+
363373
try {
364374
GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId);
365375
if (builder == null) {

src/main/java/org/jenkinsci/plugins/ghprb/GhprbRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public boolean createHook() {
300300
Map<String, String> config = new HashMap<String, String>();
301301
String secret = getSecret();
302302
config.put("url", new URL(getHookUrl()).toExternalForm());
303-
config.put("insecure_ssl", "1");
303+
config.put("insecure_ssl", "0");
304304
if (!StringUtils.isEmpty(secret)) {
305305
config.put("secret", secret);
306306
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.jenkinsci.plugins.ghprb.jobdsl;
2+
3+
import javaposse.jobdsl.dsl.Context;
4+
5+
class GhprbCancelBuildsOnUpdateContext implements Context {
6+
private Boolean overrideGlobal;
7+
8+
public Boolean getOverrideGlobal() {
9+
return overrideGlobal;
10+
}
11+
12+
/**
13+
* sets the overrideGlobal value
14+
*/
15+
public void overrideGlobal(Boolean overrideGlobal) {
16+
this.overrideGlobal = overrideGlobal;
17+
}
18+
}

src/main/java/org/jenkinsci/plugins/ghprb/jobdsl/GhprbExtensionContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javaposse.jobdsl.dsl.Context;
44
import javaposse.jobdsl.plugin.ContextExtensionPoint;
55
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
6+
import org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate;
67
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus;
78
import org.jenkinsci.plugins.ghprb.extensions.comments.GhprbCommentFile;
89
import org.jenkinsci.plugins.ghprb.extensions.status.GhprbSimpleStatus;
@@ -51,6 +52,16 @@ void commentFilePath(Runnable closure) {
5152
extensions.add(new GhprbCommentFile(context.getCommentFilePath()));
5253
}
5354

55+
/**
56+
* Overrides global settings for cancelling builds when a PR was updated
57+
*/
58+
void cancelBuildsOnUpdate(Runnable closure) {
59+
GhprbCancelBuildsOnUpdateContext context = new GhprbCancelBuildsOnUpdateContext();
60+
ContextExtensionPoint.executeInContext(closure, context);
61+
62+
extensions.add(new GhprbCancelBuildsOnUpdate(context.getOverrideGlobal()));
63+
}
64+
5465
public List<GhprbExtension> getExtensions() {
5566
return extensions;
5667
}

0 commit comments

Comments
 (0)