From 53e149a7ea89190ae32497ffa275d152100d9fcf Mon Sep 17 00:00:00 2001 From: delarea Date: Thu, 12 Sep 2024 10:42:01 +0300 Subject: [PATCH] Move the get version to start --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 3 ++- .../plugins/jfrog/integration/JFrogInstallationITest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index 99d56ef9..3a2d6591 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -83,8 +83,10 @@ public JfStep(Object args) { @Override public void perform(@NonNull Run run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher, @NonNull TaskListener listener) throws InterruptedException, IOException { workspace.mkdirs(); + this.isWindows = !launcher.isUnix(); this.jfrogBinaryPath = getJFrogCLIPath(env, isWindows); + this.currentCliVersion = getJfrogCliVersion(launcher.launch().envs(env).pwd(workspace)); // Build the 'jf' command ArgumentListBuilder builder = new ArgumentListBuilder(); @@ -167,7 +169,6 @@ public Launcher.ProcStarter setupJFrogEnvironment(Run run, EnvVars env, La FilePath jfrogHomeTempDir = Utils.createAndGetJfrogCliHomeTempDir(workspace, String.valueOf(run.getNumber())); CliEnvConfigurator.configureCliEnv(env, jfrogHomeTempDir.getRemote(), jfrogCliConfigEncryption); Launcher.ProcStarter jfLauncher = launcher.launch().envs(env).pwd(workspace).stdout(listener); - this.currentCliVersion = getJfrogCliVersion(launcher.launch().envs(env).pwd(workspace)); // Configure all servers, skip if all server ids have already been configured. if (shouldConfig(jfrogHomeTempDir)) { logIfNoToolProvided(env, listener); diff --git a/src/test/java/io/jenkins/plugins/jfrog/integration/JFrogInstallationITest.java b/src/test/java/io/jenkins/plugins/jfrog/integration/JFrogInstallationITest.java index a73b7dd4..79138eac 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/integration/JFrogInstallationITest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/integration/JFrogInstallationITest.java @@ -54,7 +54,8 @@ public void testJFrogCliInstallationFromArtifactory(JenkinsRule jenkins) throws // Download the latest CLI version. // Using remote repository to 'releases.jfrog.io' in the client's Artifactory. configureJfrogCliFromArtifactory(JFROG_CLI_TOOL_NAME_1, TEST_CONFIGURED_SERVER_ID, getRepoKey(TestRepository.CLI_REMOTE_REPO), true); - runPipeline(jenkins, "basic_version_command"); + WorkflowRun job = runPipeline(jenkins, "basic_version_command"); + assertTrue(job.getLog().contains("jf version ")); } // Gets JfrogInstallation directory in Jenkins work root.