Skip to content

Commit 3524dde

Browse files
authored
Merge pull request #40 from jenkinsci/fix/issue#36
Fix for branches that contains a slash
2 parents a062c90 + 84f4d81 commit 3524dde

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Example how your the webhook in Gogs should look like:
1616
This project has some integration tests available. For more details see the [dedicated readme](about_integration_tests.md).
1717

1818
### Change Log
19+
#### Version 1.0.14 (Apr 4, 2018)
20+
- Fixes `job not found` if slashes are used in branch [[GH_ISSUE#36](https://github.com/jenkinsci/gogs-webhook-plugin/issues/36)/[PR#40](https://github.com/jenkinsci/gogs-webhook-plugin/pull/40)].
21+
1922
#### Version 1.0.13 (Mar 16, 2018)
2023
- Fixes `job not found` if folders are used [[GH_ISSUE#36](https://github.com/jenkinsci/gogs-webhook-plugin/issues/36)/[PR#37](https://github.com/jenkinsci/gogs-webhook-plugin/pull/37)].
2124

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -13,7 +14,7 @@
1314

1415
<properties>
1516
<jenkins.version>1.625.3</jenkins.version>
16-
<java.level>7</java.level>
17+
<java.level>8</java.level>
1718
<jenkins-test-harness.version>2.13</jenkins-test-harness.version>
1819
<java.level.test>8</java.level.test>
1920
</properties>

src/main/java/org/jenkinsci/plugins/gogs/GogsWebHook.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ associated documentation files (the "Software"), to deal in the Software without
4242
import java.io.UnsupportedEncodingException;
4343
import java.net.URLDecoder;
4444
import java.nio.charset.Charset;
45+
import java.util.Arrays;
4546
import java.util.LinkedHashMap;
47+
import java.util.List;
4648
import java.util.Map;
4749
import java.util.logging.Logger;
4850

@@ -185,7 +187,13 @@ public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException
185187
} else {
186188
String ref = (String) jsonObject.get("ref");
187189
String[] components = ref.split("/");
188-
ref = components[components.length - 1];
190+
if (components.length > 3) {
191+
/* refs contains branch/tag with a slash */
192+
List<String> test = Arrays.asList(ref.split("/"));
193+
ref = String.join("%2F", test.subList(2, test.size()));
194+
} else {
195+
ref = components[components.length - 1];
196+
}
189197

190198
job = GogsUtils.find(jobName + "/" + ref, Job.class);
191199

0 commit comments

Comments
 (0)