Skip to content

Commit 215e8b3

Browse files
Surya-KolliSuryakumari Kolli
andauthored
EIB: Jenkins job not getting triggered after version uplift to 2.222.3 (#474)
* [DURACI 20476] EIB: Jenkibs job not getting triggered after jenkins uplift to 2.222.3 * [DURACI 20476] EIB: Jenkibs job not getting triggered after jenkins uplift to 2.222.3 Co-authored-by: Suryakumari Kolli <suryakumari.kolli@ericsson.com>
1 parent ce574ff commit 215e8b3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.github.ericsson</groupId>
88
<artifactId>eiffel-intelligence</artifactId>
9-
<version>2.2.3</version>
9+
<version>2.2.4</version>
1010
<packaging>war</packaging>
1111

1212
<parent>

src/main/java/com/ericsson/ei/notifications/JenkinsCrumb.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ public JsonNode fetchJenkinsCrumb(String encoding, String url)
9595
*/
9696
private URL buildJenkinsCrumbUrl(String url) throws MalformedURLException {
9797
String baseUrl = urlParser.extractBaseUrl(url);
98-
URL jenkinsCrumbUrl = new URL(baseUrl + JENKINS_CRUMB_ENDPOINT);
98+
String contextPath = urlParser.extractContextPath(url).split("/")[1];
99+
URL jenkinsCrumbUrl;
100+
if (contextPath.equals("job")) {
101+
jenkinsCrumbUrl = new URL(baseUrl + JENKINS_CRUMB_ENDPOINT);
102+
} else {
103+
String jenkinsBaseUrl = String.format("%s/%s", baseUrl, contextPath);
104+
jenkinsCrumbUrl = new URL(jenkinsBaseUrl + JENKINS_CRUMB_ENDPOINT);
105+
}
99106
return jenkinsCrumbUrl;
100107
}
101108
}

src/main/java/com/ericsson/ei/notifications/UrlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String extractBaseUrl(String url) throws MalformedURLException {
104104
* @throws MalformedURLException
105105
* @throws URISyntaxException
106106
*/
107-
private String extractContextPath(String url) throws MalformedURLException {
107+
public String extractContextPath(String url) throws MalformedURLException {
108108
URL absoluteUrl = new URL(url);
109109
String contextPath = absoluteUrl.getPath();
110110
return contextPath;

src/test/java/com/ericsson/ei/notifications/JenkinsCrumbTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class JenkinsCrumbTest {
4242

4343
private static final String URL = "http://www.somehot.com/some-endpoint/";
4444
private static final String BASE_URL = "http://www.somehot.com";
45-
private static final String JENKINS_CRUMB_URL = "http://www.somehot.com/crumbIssuer/api/json";
45+
private static final String CONTEXT_PATH = "/some-endpoint";
46+
private static final String JENKINS_CRUMB_URL = "http://www.somehot.com/some-endpoint/crumbIssuer/api/json";
4647
private static final String USERNAME = "username";
4748
private static final String PASSWORD = "password";
4849

@@ -65,6 +66,7 @@ public class JenkinsCrumbTest {
6566
public void beforeTests() throws IOException {
6667
encoding = Base64.getEncoder().encodeToString((USERNAME + ":" + PASSWORD).getBytes());
6768
when(urlParser.extractBaseUrl(URL)).thenReturn(BASE_URL);
69+
when(urlParser.extractContextPath(URL)).thenReturn(CONTEXT_PATH);
6870

6971
headers.add("Authorization", "Basic " + encoding);
7072
headers.setContentType(MediaType.APPLICATION_JSON);

0 commit comments

Comments
 (0)