Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Sep 12, 2024
1 parent 53e149a commit 6d5121a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/io/jenkins/plugins/jfrog/JfStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ 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));
// Initialize values to be used across the class
initClassValues(workspace, env, launcher);

// Build the 'jf' command
ArgumentListBuilder builder = new ArgumentListBuilder();
Expand Down Expand Up @@ -294,6 +292,21 @@ private void logIllegalBuildPublishOutput(Log log, ByteArrayOutputStream taskOut
log.warn("Illegal build-publish output: " + taskOutputStream.toString(StandardCharsets.UTF_8));
}

/**
* initialize values to be used across the class.
* @param env environment variables applicable to this step
* @param launcher a way to start processes
* @param workspace a workspace to use for any file operations
* @throws IOException in case of any I/O error, or we failed to run the 'jf'
* @throws InterruptedException if the step is interrupted
*/
private void initClassValues(FilePath workspace, EnvVars env, Launcher launcher) throws IOException, InterruptedException {
this.isWindows = !launcher.isUnix();
this.jfrogBinaryPath = getJFrogCLIPath(env, isWindows);
Launcher.ProcStarter procStarter = launcher.launch().envs(env).pwd(workspace);
this.currentCliVersion = getJfrogCliVersion(procStarter);
}

@Symbol("jf")
@Extension
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {
Expand Down

0 comments on commit 6d5121a

Please sign in to comment.