diff --git a/plugin-files/provar-automation.hpi b/plugin-files/provar-automation.hpi index 3646ea7..bc60775 100644 Binary files a/plugin-files/provar-automation.hpi and b/plugin-files/provar-automation.hpi differ diff --git a/pom.xml b/pom.xml index a1473a7..e50fbdd 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ 999999-SNAPSHOT - 2.387.3 + 2.401.3 jenkinsci/${project.artifactId}-plugin @@ -41,8 +41,8 @@ io.jenkins.tools.bom - bom-2.387.x - 2102.v854b_fec19c92 + bom-2.401.x + 2675.v1515e14da_7a_6 pom import diff --git a/source-files/build_folders_provar_plugin.xml b/source-files/build_folders_provar_plugin.xml index e708a8b..3793833 100644 --- a/source-files/build_folders_provar_plugin.xml +++ b/source-files/build_folders_provar_plugin.xml @@ -28,6 +28,7 @@ pluginOutputlevel="WARNING" stopTestRunOnError="false" secretsPassword="${secrets.password}" + licensePath="${env.LICENSE_PATH}" > diff --git a/source-files/build_provar_plugin.xml b/source-files/build_provar_plugin.xml index cfc4792..0c554c5 100644 --- a/source-files/build_provar_plugin.xml +++ b/source-files/build_provar_plugin.xml @@ -28,6 +28,7 @@ pluginOutputlevel="WARNING" stopTestRunOnError="false" secretsPassword="${secrets.password}" + licensePath="${env.LICENSE_PATH}" > diff --git a/source-files/io.jenkins.plugins.ProvarAutomation.ProvarAutomationInstaller b/source-files/io.jenkins.plugins.ProvarAutomation.ProvarAutomationInstaller index 79be688..ac49341 100644 --- a/source-files/io.jenkins.plugins.ProvarAutomation.ProvarAutomationInstaller +++ b/source-files/io.jenkins.plugins.ProvarAutomation.ProvarAutomationInstaller @@ -1,4 +1,5 @@ {"list":[{"id":"latest","name":"latest","url":"https://provar-installers.s3-us-west-2.amazonaws.com/latest/Provar_ANT_latest.zip"}, +{"id":"2.11.3","name":"2.11.3","url":"https://provar-installers.s3-us-west-2.amazonaws.com/2.11.3/Provar_ANT_2.11.3.11.zip"}, {"id":"2.11.2","name":"2.11.2","url":"https://provar-installers.s3-us-west-2.amazonaws.com/2.11.2/Provar_ANT_2.11.2.05.zip"}, {"id":"2.11.1","name":"2.11.1","url":"https://provar-installers.s3-us-west-2.amazonaws.com/2.11.1/Provar_ANT_2.11.1.04.zip"}, {"id":"2.10.2","name":"2.10.2","url":"https://provar-installers.s3-us-west-2.amazonaws.com/2.10.2/Provar_ANT_2.10.2.07.zip"}, diff --git a/src/main/java/io/jenkins/plugins/ProvarAutomation.java b/src/main/java/io/jenkins/plugins/ProvarAutomation.java index 59c05d5..976ee10 100644 --- a/src/main/java/io/jenkins/plugins/ProvarAutomation.java +++ b/src/main/java/io/jenkins/plugins/ProvarAutomation.java @@ -88,6 +88,8 @@ public enum ResultsPathSettings { private final ResultsPathSettings resultsPathSetting; @NonNull private final String projectName; + @NonNull + private final String licensePath; @DataBoundConstructor public ProvarAutomation(@NonNull String provarAutomationName, @@ -99,17 +101,19 @@ public ProvarAutomation(@NonNull String provarAutomationName, @NonNull Secret secretsPassword, @NonNull SalesforceMetadataCacheSettings salesforceMetadataCacheSetting, @NonNull ResultsPathSettings resultsPathSetting, - @NonNull String projectName) { + @NonNull String projectName, + @NonNull String licensePath) { this.provarAutomationName = provarAutomationName; - this.buildFile = Util.fixEmptyAndTrim(buildFile); - this.testPlan = Util.fixEmptyAndTrim(testPlan); - this.testFolder = Util.fixEmptyAndTrim(testFolder); + this.buildFile = Objects.requireNonNull(buildFile); + this.testPlan = Objects.requireNonNull(testPlan); + this.testFolder = Objects.requireNonNull(testFolder); this.browser = browser; this.environment = environment; this.secretsPassword = Objects.requireNonNull(secretsPassword); this.salesforceMetadataCacheSetting = salesforceMetadataCacheSetting; this.resultsPathSetting = resultsPathSetting; this.projectName = projectName; + this.licensePath = Objects.requireNonNull(licensePath); } /** @@ -150,6 +154,8 @@ public Secret getSecretsPassword() { public ResultsPathSettings getResultsPathSetting() { return resultsPathSetting; } @NonNull public String getProjectName() { return projectName; } + @NonNull + public String getLicensePath() { return licensePath; } @Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { @@ -170,7 +176,6 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene listener.getLogger().println("Running the build file: " + buildFile); listener.getLogger().println("Executing test plan: " + testPlan); listener.getLogger().println("Executing test folder: " + testFolder); - listener.getLogger().println("Target environment: " + environment); listener.getLogger().println("Target browser: " + browser); if (secretsPassword.getPlainText() != null) { @@ -178,11 +183,15 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene } listener.getLogger().println("Salesforce Metadata Cache Setting: " + salesforceMetadataCacheSetting); listener.getLogger().println("Results Path Setting: " + resultsPathSetting); + String licensePath = env.expand(this.licensePath); + if (licensePath.isEmpty()) { + licensePath = DescriptorImpl.defaultLicensePath; + } + listener.getLogger().println("Execution license path being used: " + licensePath); listener.getLogger().println("Workspace: " + workspaceFilePath); ArgumentListBuilder args = new ArgumentListBuilder(); - // Allow empty build parameters to be used in property replacements. // The env.override/overrideAll methods remove the property if it's an empty string. for (Map.Entry e : build.getBuildVariables().entrySet()) { @@ -212,14 +221,14 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene // Some default/empty value handling for test plans/folders // ProvarProject/tests/ will run all tests - if (testPlan != null) { + if (!testPlan.isEmpty()) { env.put("TEST_PLAN", testPlan); } else { env.put("TEST_PLAN", " "); } if (testFolder.equalsIgnoreCase("All")) { env.put("TEST_FOLDER", "/"); - } else if (testFolder != null) { + } else if (!testFolder.isEmpty()) { env.put("TEST_FOLDER", testFolder); } else { env.put("TEST_FOLDER", " "); @@ -232,6 +241,7 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene env.put("CACHE_SETTING", salesforceMetadataCacheSetting.name()); env.put("RESULTS_PATH_SETTING", resultsPathSetting.name()); env.put("PROJECT_NAME", projectName); + env.put("LICENSE_PATH", licensePath); VariableResolver vr = new VariableResolver.ByMap<>(env); FilePath buildFilePath = buildFilePath(build.getModuleRoot(), buildFile, env.expand(projectName)); @@ -433,6 +443,18 @@ public FormValidation doCheckProjectName(@QueryParameter String value) return FormValidation.ok(); } + @POST + public FormValidation doCheckLicensePath(@QueryParameter String value) + throws IOException, ServletException { + if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { + return FormValidation.ok(); + } + if (value.length() == 0) { + return FormValidation.warning(Messages.ProvarAutomation_DescriptorImpl_warnings_missingLicensePath()); + } + + return FormValidation.ok(); + } @Override public boolean isApplicable(Class aClass) { @@ -450,7 +472,6 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti return true; } - public static final String defaultProvarAutomationName = ""; public static final String defaultProjectName = "ProvarProject"; public static final String defaultBuildFile = "build.xml"; @@ -458,6 +479,10 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti public static final String defaultEnvironment = ""; public static final String defaultTestPlan = "Regression"; public static final String defaultTestFolder = "All"; + static String windowsLicensePath = "C:\\Users\\" + System.getProperty("user.name") + "\\Provar\\.licenses"; + static String unixLicensePath = System.getenv("HOME") + "/Provar/.licenses"; + static String osName = System.getProperty("os.name"); + public static final String defaultLicensePath = osName.contains("Windows") ? windowsLicensePath : unixLicensePath; public static final SalesforceMetadataCacheSettings defaultSalesforceMetadataCacheSetting = SalesforceMetadataCacheSettings.Reuse; public static final ResultsPathSettings defaultResultsPathSetting = ResultsPathSettings.Increment; diff --git a/src/main/resources/io/jenkins/plugins/Messages.properties b/src/main/resources/io/jenkins/plugins/Messages.properties index 8453180..57464c2 100644 --- a/src/main/resources/io/jenkins/plugins/Messages.properties +++ b/src/main/resources/io/jenkins/plugins/Messages.properties @@ -3,6 +3,7 @@ ProvarAutomation.DescriptorImpl.warnings.missingTestFolder=Test Folder is missin ProvarAutomation.DescriptorImpl.warnings.missingTestPlan=Test Plan name is missing ProvarAutomation.DescriptorImpl.warnings.noSecretsPassword=Your project is missing a secrets password ProvarAutomation.DescriptorImpl.warnings.projectFolderMissing=Project folder name is missing, make sure the root of your repo contains a Provar Project +ProvarAutomation.DescriptorImpl.warnings.missingLicensePath=License path is missing ProvarAutomation.DescriptorImpl.DisplayName=Run Provar Automation Tests ProvarAutomation.ToolInstallation.DescriptorImpl.DisplayName=Provar Automation CLI ProvarAutomation.AntExecutionFailed=command execution failed. diff --git a/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.jelly b/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.jelly index aa69b94..cc5e2bd 100644 --- a/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.jelly +++ b/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.jelly @@ -53,10 +53,15 @@ THE SOFTWARE. description="${%TestFolderDescr}"> + + + + diff --git a/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.properties b/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.properties index 632a8d6..9e2e051 100644 --- a/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.properties +++ b/src/main/resources/io/jenkins/plugins/ProvarAutomation/config.properties @@ -17,4 +17,6 @@ SecretsPasswordDescr=The secrets password used to encrypt the project SalesforceMetadataCacheSetting=Salesforce Metadata Cache Setting SalesforceMetadataCacheSettingDescr=The Salesforce metadata cache refresh setting ResultsPathSetting=Test Results Path Setting -ResultsPathSettingDescr=How to handle the results directory before the next run \ No newline at end of file +ResultsPathSettingDescr=How to handle the results directory before the next run +LicensePath=Execution License Path +LicensePathDescr=The path of the '.licenses' directory on the machine being used to run Provar tests \ No newline at end of file diff --git a/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-buildFile.html b/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-buildFile.html index be492be..cebfe48 100644 --- a/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-buildFile.html +++ b/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-buildFile.html @@ -1,4 +1,4 @@
- The name of the build file. Must end with '.xml'. + The name of the build file. Can end with '.xml' or just be the base file name. This task assumes it is contained in the ANT folder of your Project Name directory.
diff --git a/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-licensePath.html b/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-licensePath.html new file mode 100644 index 0000000..277c650 --- /dev/null +++ b/src/main/resources/io/jenkins/plugins/ProvarAutomation/help-licensePath.html @@ -0,0 +1,5 @@ +
+ The path of your license directory on the machine being used to run the tests.
+ Your license directory should contain a ".licenses" folder.
+ If left empty, will default to $USER_HOME/Provar/.licenses. +
\ No newline at end of file diff --git a/src/test/java/io/jenkins/plugins/ProvarAutomationTest.java b/src/test/java/io/jenkins/plugins/ProvarAutomationTest.java index ed64dcb..624f39b 100644 --- a/src/test/java/io/jenkins/plugins/ProvarAutomationTest.java +++ b/src/test/java/io/jenkins/plugins/ProvarAutomationTest.java @@ -50,6 +50,10 @@ public class ProvarAutomationTest { final String testPlan = "Regression"; final String testFolder = "all"; final String environment = "Dev"; + static String windowsLicensePath = "C:/Users/" + System.getProperty("user.name") + "/Provar/.licenses"; + static String unixLicensePath = System.getenv("HOME") + "/Provar/.licenses"; + static String osName = System.getProperty("os.name"); + final String licensePath = osName.contains("Windows") ? windowsLicensePath : unixLicensePath; final ProvarAutomation.Browser browser = ProvarAutomation.Browser.Safari; final Secret secretsPassword = Secret.fromString("ProvarSecretsPasssword"); final ProvarAutomation.SalesforceMetadataCacheSettings salesforceMetadataCacheSetting = ProvarAutomation.SalesforceMetadataCacheSettings.Reload; @@ -61,7 +65,7 @@ public class ProvarAutomationTest { @Test public void testConfigRoundtrip() throws Exception { FreeStyleProject p = jr.createFreeStyleProject(); - p.getBuildersList().add(new ProvarAutomation(provarAutomationName, buildFile, testPlan, testFolder, environment, browser, secretsPassword, salesforceMetadataCacheSetting, resultsPathSetting, projectName)); + p.getBuildersList().add(new ProvarAutomation(provarAutomationName, buildFile, testPlan, testFolder, environment, browser, secretsPassword, salesforceMetadataCacheSetting, resultsPathSetting, projectName, licensePath)); WebClient webClient = jr.createWebClient(); HtmlPage page = webClient.getPage(p,"configure"); @@ -81,6 +85,7 @@ public void testConfigRoundtrip() throws Exception { assertEquals(salesforceMetadataCacheSetting,pa.getSalesforceMetadataCacheSetting()); assertEquals(resultsPathSetting,pa.getResultsPathSetting()); assertEquals(projectName,pa.getProjectName()); + assertEquals(licensePath, pa.getLicensePath()); } // TODO: Add tests for validations of file paths, specifically the build file. // TODO: Add testing for downloading of Provar CLI, extraction, and env var set. @@ -91,7 +96,7 @@ public void testConfigRoundtrip() throws Exception { @Test public void testBuild() throws Exception { FreeStyleProject project = jr.createFreeStyleProject(); - ProvarAutomation builder = new ProvarAutomation(provarAutomationName, buildFile, testPlan, testFolder, environment, browser, secretsPassword, salesforceMetadataCacheSetting, resultsPathSetting, projectName); + ProvarAutomation builder = new ProvarAutomation(provarAutomationName, buildFile, testPlan, testFolder, environment, browser, secretsPassword, salesforceMetadataCacheSetting, resultsPathSetting, projectName, licensePath); project.getBuildersList().add(builder); FreeStyleBuild build = jr.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(quietPeriod).get()); jr.assertLogContains("Running the build file: " + buildFile, build); @@ -103,8 +108,20 @@ public void testBuild() throws Exception { jr.assertLogContains("Results Path Setting: " + resultsPathSetting, build); jr.assertLogContains("Project Folder: " + projectName, build); jr.assertLogContains("Project is encrypted! Thank you for being secure.", build); + jr.assertLogContains("Execution license path being used: " + licensePath, build); } + // TODO: Add test for license path and license file +// @Test +// public void testLicense() throws Exception { +///* FreeStyleProject project = jr.createFreeStyleProject(); +// ProvarAutomation builder = new ProvarAutomation(provarAutomationName, buildFile, testPlan, testFolder, environment, browser, secretsPassword, salesforceMetadataCacheSetting, resultsPathSetting, projectName, licensePath); +// project.getBuildersList().add(builder); +// FreeStyleBuild build = jr.assertBuildStatus(Result.FAILURE, project.scheduleBuild2(quietPeriod).get()); +// Path path = Paths.get("does-not-exist.txt"); +// assertFalse(Files.exists(path));*/ +// } + @Test public void testScriptedPipeline() throws Exception { String agentLabel = "my-agent"; @@ -121,7 +138,8 @@ public void testScriptedPipeline() throws Exception { + " secretsPassword: '" + secretsPassword + "',\n" + " salesforceMetadataCacheSetting: '" + salesforceMetadataCacheSetting + "',\n" + " resultsPathSetting: '" + resultsPathSetting + "',\n" - + " projectName: '" + projectName + "'\n" + + " projectName: '" + projectName + "',\n" + + " licensePath: '" + licensePath + "'\n" + "}"; job.setDefinition(new CpsFlowDefinition(pipelineScript, true));