Compare commits

Invalid templates have been ignored

1 invalid template(s) found pull_request_template.md: frontmatter must start with a separator line

..

No commits in common. '6a0244d33490258f63e741c2b1830c00ec8080dd' and 'eceb3fdfd29b4daebeb088ad1324ce855e215777' have entirely different histories.

35
Jenkinsfile vendored

@ -5,6 +5,7 @@ pipeline {
environment { environment {
def isPendingUpstreamDependenciesExists = false def isPendingUpstreamDependenciesExists = false
def triggeredViaPush = false def triggeredViaPush = false
SCANNER_HOME = tool 'sonar-scanner'
JAVA_HOME = '/usr/lib/jvm/java-11-openjdk' JAVA_HOME = '/usr/lib/jvm/java-11-openjdk'
PATH = "${JAVA_HOME}/bin:${env.PATH}" PATH = "${JAVA_HOME}/bin:${env.PATH}"
} }
@ -48,6 +49,22 @@ pipeline {
} }
} }
stage('Check SonarQube Installation') {
steps {
script {
echo "Initial JAVA_HOME: ${env.JAVA_HOME}"
echo "Initial PATH: ${env.PATH}"
withEnv(["JAVA_HOME=${env.JAVA_HOME}", "PATH=${env.JAVA_HOME}/bin:${env.PATH}"]) {
sh """
java -version
${SCANNER_HOME}/bin/sonar-scanner --version
"""
}
}
}
}
stage('Fetch Pending Upstream Dependencies') { stage('Fetch Pending Upstream Dependencies') {
steps { steps {
script { script {
@ -95,6 +112,24 @@ pipeline {
} }
} }
stage('Code Quality Check') {
steps {
script {
def projectName = "device-mgt-core-${env.CHANGE_ID}"
def projectKey = "device-mgt-core-${env.CHANGE_ID}"
withSonarQubeEnv('sonar') {
sh """
$SCANNER_HOME/bin/sonar-scanner \
-Dsonar.projectName=${projectName} \
-Dsonar.projectKey=${projectKey} \
-Dsonar.java.binaries=target
"""
}
}
}
}
stage('Report Job Status') { stage('Report Job Status') {
steps { steps {
script { script {

@ -48,8 +48,6 @@ import org.apache.commons.validator.routines.UrlValidator;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -505,29 +503,31 @@ public class APIUtil {
applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions());
applicationRelease.setRating(applicationReleaseDTO.getRating()); applicationRelease.setRating(applicationReleaseDTO.getRating());
applicationRelease.setIconPath( applicationRelease.setIconPath(
basePath + Constants.ICON_ARTIFACT + Constants.FILE_NAME_PARAM + basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName());
URLEncoder.encode(applicationReleaseDTO.getIconName(), StandardCharsets.UTF_8));
if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){ if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){
applicationRelease.setBannerPath( applicationRelease.setBannerPath(
basePath + Constants.BANNER_ARTIFACT + Constants.FILE_NAME_PARAM + basePath + Constants.BANNER_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO
URLEncoder.encode(applicationReleaseDTO.getBannerName(), StandardCharsets.UTF_8)); .getBannerName());
} }
applicationRelease.setInstallerPath(
constructInstallerPath(applicationReleaseDTO.getInstallerName(), applicationReleaseDTO.getAppHashValue())); applicationRelease.setInstallerPath(constructInstallerPath(applicationReleaseDTO.getInstallerName(),
applicationReleaseDTO.getAppHashValue()));
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) { if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) {
screenshotPaths.add( screenshotPaths
basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FILE_NAME_PARAM + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FORWARD_SLASH + applicationReleaseDTO
URLEncoder.encode(applicationReleaseDTO.getScreenshotName1(), StandardCharsets.UTF_8)); .getScreenshotName1());
} }
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) { if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) {
screenshotPaths.add( screenshotPaths
basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FILE_NAME_PARAM + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FORWARD_SLASH + applicationReleaseDTO
URLEncoder.encode(applicationReleaseDTO.getScreenshotName2(), StandardCharsets.UTF_8)); .getScreenshotName2());
} }
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) { if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) {
screenshotPaths.add( screenshotPaths
basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FILE_NAME_PARAM + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FORWARD_SLASH + applicationReleaseDTO
URLEncoder.encode(applicationReleaseDTO.getScreenshotName3(), StandardCharsets.UTF_8)); .getScreenshotName3());
} }
applicationRelease.setScreenshots(screenshotPaths); applicationRelease.setScreenshots(screenshotPaths);
return applicationRelease; return applicationRelease;
@ -543,12 +543,9 @@ public class APIUtil {
public static String constructInstallerPath(String installerName, String appHash) throws ApplicationManagementException { public static String constructInstallerPath(String installerName, String appHash) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
UrlValidator urlValidator = new UrlValidator(); UrlValidator urlValidator = new UrlValidator();
String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + appHash + Constants.FORWARD_SLASH;
appHash + Constants.FORWARD_SLASH; return urlValidator.isValid(installerName) ? installerName
return urlValidator.isValid(installerName) : basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + installerName;
? installerName
: basePath + Constants.APP_ARTIFACT + Constants.FILE_NAME_PARAM +
URLEncoder.encode(installerName, StandardCharsets.UTF_8);
} }
public static String getArtifactDownloadBaseURL() throws ApplicationManagementException { public static String getArtifactDownloadBaseURL() throws ApplicationManagementException {

@ -140,11 +140,6 @@ public class Constants {
public static final String DB_TYPE_POSTGRESQL = "PostgreSQL"; public static final String DB_TYPE_POSTGRESQL = "PostgreSQL";
} }
/**
* Query parameter for specifying the filename in the App artifact URL.
*/
public static final String FILE_NAME_PARAM = "?fileName=";
/** /**
* Directory name of the icon artifact that are saved in the file system. * Directory name of the icon artifact that are saved in the file system.
*/ */

Loading…
Cancel
Save