diff --git a/common/src/main/java/org/wso2/testgrid/common/TestGridConstants.java b/common/src/main/java/org/wso2/testgrid/common/TestGridConstants.java index e8ebe570b..47c81fa23 100644 --- a/common/src/main/java/org/wso2/testgrid/common/TestGridConstants.java +++ b/common/src/main/java/org/wso2/testgrid/common/TestGridConstants.java @@ -27,13 +27,14 @@ */ public class TestGridConstants { - public static final String TESTGRID_YAML = ".testgrid.yaml"; + public static final String TESTGRID_YAML = "testgrid.yaml"; public static final String TEST_PLAN_YAML_PREFIX = "test-plan"; public static final String TESTGRID_LOG_FILE_NAME = "testgrid.log"; public static final String TESTGRID_LOGS_DIR = "logs"; public static final String PRODUCT_TEST_PLANS_DIR = "test-plans"; public static final String FILE_SEPARATOR = "/"; + public static final String HIDDEN_FILE_INDICATOR = "."; public static final String LOG_FILE_EXTENSION = ".log"; public static final String WORKSPACE = "workspace"; diff --git a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java index 08ae51e77..ed6968efa 100644 --- a/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java +++ b/core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java @@ -349,19 +349,17 @@ private TestgridYaml buildTestgridYamlContent(JobConfigFile jobConfigFile) { StringBuilder testgridYamlBuilder = new StringBuilder(); String ls = System.lineSeparator(); testgridYamlBuilder - .append(getTestgridYamlFor(Paths.get(infraRepositoryLocation, TestGridConstants.TESTGRID_YAML))) + .append(getTestgridYamlFor(getTestGridYamlLocation(infraRepositoryLocation))) .append(ls); String testgridYamlContent = testgridYamlBuilder.toString().trim(); if (!testgridYamlContent.isEmpty()) { if (!testgridYamlContent.contains("deploymentConfig")) { testgridYamlBuilder - .append(getTestgridYamlFor( - Paths.get(deployRepositoryLocation, TestGridConstants.TESTGRID_YAML))) + .append(getTestgridYamlFor(getTestGridYamlLocation(deployRepositoryLocation))) .append(ls); } testgridYamlBuilder - .append(getTestgridYamlFor( - Paths.get(scenarioTestsRepositoryLocation, TestGridConstants.TESTGRID_YAML))) + .append(getTestgridYamlFor(getTestGridYamlLocation(scenarioTestsRepositoryLocation))) .append(ls); } else { logger.warn(StringUtil.concatStrings( @@ -630,4 +628,20 @@ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property } } } + + /** + * If the testgrid yaml file is hidden in the directory, change the URI as to refer the hidden file. + * @param directory directory where the testgrid yaml file exists + * @return testgrid yaml file path + */ + private Path getTestGridYamlLocation(String directory) { + Path hiddenYamlPath = Paths.get( + directory, TestGridConstants.HIDDEN_FILE_INDICATOR + TestGridConstants.TESTGRID_YAML); + Path defaultYamlPath = Paths.get(directory, TestGridConstants.TESTGRID_YAML); + if (Files.exists(hiddenYamlPath)) { + return hiddenYamlPath; + } else { + return defaultYamlPath; + } + } }