Skip to content

Commit

Permalink
Merge pull request #16 from jenkinsci/feature/modernizing-plugin
Browse files Browse the repository at this point in the history
updated parent pom to 4.72, allow compile for java 11
  • Loading branch information
ravin-accelq authored Aug 16, 2023
2 parents a7a7c0f + 8ccb10a commit f4e37a7
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildPlugin(
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 11],
[platform: 'linux', jdk: 17],
[platform: 'windows', jdk: 11],
])
2 changes: 1 addition & 1 deletion aqconnect.iml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.jcip:jcip-annotations:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<!-- <orderEntry type="library" scope="TEST" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> -->
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jenkins-ci.main:jenkins-core:1.625.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jenkins-ci.plugins.icon-shim:icon-set:1.0.5" level="project" />
Expand Down
44 changes: 0 additions & 44 deletions core/.classpath

This file was deleted.

34 changes: 0 additions & 34 deletions core/.project

This file was deleted.

98 changes: 0 additions & 98 deletions core/pom.xml

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file removed core/target/classes/aqPluginCore/AQConstants.class
Binary file not shown.
Binary file removed core/target/classes/aqPluginCore/AQException.class
Binary file not shown.
Binary file not shown.
Binary file removed core/target/classes/aqPluginCore/AQRestClient$1.class
Binary file not shown.
Binary file removed core/target/classes/aqPluginCore/AQRestClient.class
Binary file not shown.
Binary file removed core/target/classes/aqPluginCore/AQUtils.class
Binary file not shown.
Binary file removed core/target/core-1.0-SNAPSHOT.jar
Binary file not shown.
4 changes: 0 additions & 4 deletions core/target/maven-archiver/pom.properties

This file was deleted.

15 changes: 4 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.16</version>
<version>4.72</version>
<relativePath />
</parent>
<groupId>com.aq</groupId>
Expand All @@ -17,9 +17,9 @@
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/accelq-ci-connect-plugin</gitHubRepo>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<jenkins.version>2.222.3</jenkins.version>
<java.level>8</java.level>
<jenkins-test-harness.version>2.71</jenkins-test-harness.version>
<jenkins.version>2.401.3</jenkins.version>
<java.level>11</java.level>
<!-- <jenkins-test-harness.version>2.71</jenkins-test-harness.version> -->
<extn>hpi</extn>
</properties>

Expand Down Expand Up @@ -75,12 +75,5 @@
<artifactId>json-simple</artifactId>
<version>[1.1.1,)</version>
</dependency>
<dependency>
<groupId>core</groupId>
<artifactId>aqCore</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/lib/core-1.0-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
</project>
Binary file removed src/lib/core-1.0-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aqPluginCore;
package com.aq.aqconnect;

public class AQConstants {
public static final String LOG_DELIMITER = ">>> ";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package aqPluginCore;
package com.aq.aqconnect;


public class AQException extends RuntimeException{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package aqPluginCore;
package com.aq.aqconnect;


import java.net.URL;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -44,7 +45,8 @@ public String validateAPIKey(String value) {
}
public String validateUserId(String value) {
try {
String emailRegex = "^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$";
String emailRegex = "^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@"
+ "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$";
Pattern pat = Pattern.compile(emailRegex);
if (value == null || value.length() == 0) return "Cannot be empty";
else if (!pat.matcher(value).matches()) return "User ID must be in email format";
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/aq/aqconnect/AQPluginBuilderAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import javax.servlet.ServletException;
import java.io.IOException;
import java.io.PrintStream;
import aqPluginCore.*;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.verb.POST;
import org.json.simple.parser.ParseException;
Expand Down Expand Up @@ -105,7 +104,7 @@ public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnul
JSONObject summaryObj = null;
long realJobPid = 0;
try {
aqRestClient = AQRestClient.getInstance();
aqRestClient = new AQRestClient();
AQUtils aqUtils = new AQUtils();
aqRestClient.setUpBaseURL(this.appURL, this.tenantCode);
aqRestClient.disableSSLChecks(this.disableSSLCheck);
Expand Down Expand Up @@ -300,7 +299,7 @@ public FormValidation doTestConnection(@QueryParameter("appURL") final String ap
// make call to backend to validate it
AQRestClient aqRestClient = null;
AQUtils aqUtils = new AQUtils();
aqRestClient = AQRestClient.getInstance();
aqRestClient = new AQRestClient();
String payload = aqUtils.getRunParamJsonPayload(runParamStr);
aqRestClient.setUpBaseURL(appURL, tenantCode);
aqRestClient.disableSSLChecks(disableSSLCheck);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package aqPluginCore;
package com.aq.aqconnect;


import org.apache.http.HttpHost;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand All @@ -21,27 +22,25 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

public class AQRestClient {


private static final AQRestClient aqRESTClient = new AQRestClient();
private final JSONParser jsonParser = new JSONParser();

//Base URL and extensions
private static String BASE_URL;
private static String API_ENDPOINT;

private static int PROXY_PORT = 80;
private static String PROXY_HOST;
private static Boolean DISABLE_SSL_CHECKS = false;

private String BASE_URL;
private String API_ENDPOINT;
private int PROXY_PORT = 80;
private String PROXY_HOST;
private Boolean DISABLE_SSL_CHECKS = false;

public static AQRestClient getInstance() {
return aqRESTClient;
}

public String getBaseURL() {
return BASE_URL;
Expand All @@ -60,7 +59,7 @@ public void setUpBaseURL(String baseURL, String tenantCode) {
API_ENDPOINT = BASE_URL + "awb/api/" + AQConstants.API_VERSION + "/" + tenantCode;
}

private CloseableHttpClient getHttpsClient() {
private CloseableHttpClient getHttpsClient(){
try {
HttpClientBuilder hcb = null;
if (DISABLE_SSL_CHECKS) {
Expand All @@ -85,7 +84,11 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce
}
CloseableHttpClient client = hcb.build();
return client;
} catch(Exception e) {
}catch(NoSuchAlgorithmException e){
return null;
}catch(KeyStoreException e){
return null;
}catch(KeyManagementException e){
return null;
}
}
Expand All @@ -102,7 +105,7 @@ public JSONObject getJobSummary(long runPid, String apiKey, String userId) {
CloseableHttpResponse httpResponse = httpClient.execute(httpGet);

BufferedReader reader = new BufferedReader(new InputStreamReader(
httpResponse.getEntity().getContent()));
httpResponse.getEntity().getContent(), StandardCharsets.UTF_8));
String inputLine;
StringBuffer response = new StringBuffer();

Expand Down Expand Up @@ -134,7 +137,7 @@ public JSONObject triggerJob(String apiKey, String userId, String jobId, String
try {
CloseableHttpResponse httpResponse = httpClient.execute(httpPut);
BufferedReader reader = new BufferedReader(new InputStreamReader(
httpResponse.getEntity().getContent()));
httpResponse.getEntity().getContent(), StandardCharsets.UTF_8));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = reader.readLine()) != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package aqPluginCore;
package com.aq.aqconnect;

import org.apache.http.entity.StringEntity;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
Expand Down

0 comments on commit f4e37a7

Please sign in to comment.