Skip to content

Commit

Permalink
Merge pull request #58 from jenkinsci/config-as-code
Browse files Browse the repository at this point in the history
Fix for not allowed characters for cxOrigin field
  • Loading branch information
SubhadraSahoo authored Feb 11, 2021
2 parents 54c4918 + 9b219e3 commit 0951ec0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description = Provides automatic scan of code by Checkmarx server and shows results summary and trend in Jenkins interface.
group = com.checkmarx.jenkins
version = 2021.1.1
version = 2021.1.2

repositoryVersion=

Expand Down
12 changes: 4 additions & 8 deletions src/main/java/com/checkmarx/jenkins/CxScanBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ private String getJenkinURLForTheJob(EnvVars env) {
try {
String jobName = env.get("JOB_NAME");
jobName = URLDecoder.decode(jobName, "UTF-8");
jobName = jobName.replaceAll("[^.a-zA-Z0-9\\s]", " ");
String jenURL = env.get("JENKINS_URL");
jenURL = jenURL.substring((jenURL.lastIndexOf("://")) + 3);
String hostName = "";
Expand All @@ -1160,13 +1161,14 @@ private String getJenkinURLForTheJob(EnvVars env) {
} else {
hostName = jenURL;
}
passedURL = hostName + " " + jobName;
passedURL = "Jenkins " + hostName + " " + jobName;
// 50 is the maximum number of characters allowed by SAST server
if(passedURL.length()>50)
passedURL=passedURL.substring(0,50);
else
passedURL=passedURL;
} catch (UnsupportedEncodingException e) {
log.error("Failed to get jwnkin URL of the JOB: " + e.getMessage());
log.error("Failed to get Jenkins URL of the JOB: " + e.getMessage());
}
return passedURL;
}
Expand All @@ -1175,12 +1177,6 @@ private String getJenkinURLForTheJob(EnvVars env) {
private String getCxOriginUrl(EnvVars env, CxLoggerAdapter log) {
String jenURL = env.get("JENKINS_URL");
String jobName = env.get("JOB_NAME");
try {
jobName = URLDecoder.decode(jobName, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error("Failed to get jenkin URL of the JOB: " + e.getMessage());
}

String originUrl = jenURL+"job/"+jobName;
return originUrl;
}
Expand Down

0 comments on commit 0951ec0

Please sign in to comment.