Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect JCasC configuration for latest JFrog CLI #98

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/main/java/io/jenkins/plugins/jfrog/ArtifactoryInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import io.jenkins.plugins.jfrog.configuration.JFrogPlatformBuilder;
import io.jenkins.plugins.jfrog.configuration.JFrogPlatformInstance;
import io.jenkins.plugins.jfrog.plugins.PluginsUtils;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.jfrog.build.client.Version;
import org.kohsuke.stapler.DataBoundConstructor;
Expand All @@ -26,6 +28,7 @@
*
* @author gail
*/
@Getter
@SuppressWarnings("unused")
public class ArtifactoryInstaller extends BinaryInstaller {
private static final Version MIN_CLI_VERSION = new Version("2.6.1");
Expand All @@ -35,7 +38,8 @@ public class ArtifactoryInstaller extends BinaryInstaller {

final String serverId;
final String repository;
final String version;
@Setter
String version;

@DataBoundConstructor
public ArtifactoryInstaller(String serverId, String repository, String version) {
Expand All @@ -45,18 +49,6 @@ public ArtifactoryInstaller(String serverId, String repository, String version)
this.version = StringUtils.trim(version);
}

public String getServerId() {
return serverId;
}

public String getRepository() {
return repository;
}

public String getVersion() {
return version;
}

@Override
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException {
JFrogPlatformInstance server = getSpecificServer(getServerId());
Expand All @@ -72,7 +64,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
*/
JFrogPlatformInstance getSpecificServer(String id) {
List<JFrogPlatformInstance> jfrogInstances = JFrogPlatformBuilder.getJFrogPlatformInstances();
if (jfrogInstances != null && jfrogInstances.size() > 0) {
if (jfrogInstances != null && !jfrogInstances.isEmpty()) {
for (JFrogPlatformInstance jfrogPlatformInstance : jfrogInstances) {
if (jfrogPlatformInstance.getId().equals(id)) {
// Getting credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public JfrogInstallation newInstance(StaplerRequest req, JSONObject formData) th
public List<? extends ToolInstaller> getDefaultInstallers() {
List<ToolInstaller> installersList = new ArrayList<>();
// The default installation will be from 'releases.jfrog.io'
installersList.add(new ReleasesInstaller(null));
installersList.add(new ReleasesInstaller());
return installersList;
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/io/jenkins/plugins/jfrog/ReleasesInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.jenkins.plugins.jfrog.configuration.JFrogPlatformInstance;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.verb.POST;

Expand All @@ -23,8 +24,13 @@ public class ReleasesInstaller extends ArtifactoryInstaller {
private static final String RELEASES_REPOSITORY = "jfrog-cli";

@DataBoundConstructor
public ReleasesInstaller(String version) {
super("", RELEASES_REPOSITORY, version);
public ReleasesInstaller() {
super("", RELEASES_REPOSITORY, "");
}

@DataBoundSetter
public void setVersion(String version) {
super.setVersion(version);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ private String readPipeline(String name) throws IOException {
}

public static void configureJfrogCliFromReleases(String cliVersion, Boolean override) throws Exception {
configureJfrogCliTool(JFROG_CLI_TOOL_NAME_1, new ReleasesInstaller(cliVersion), override);
ReleasesInstaller releasesInstaller = new ReleasesInstaller();
releasesInstaller.setVersion(cliVersion);
configureJfrogCliTool(JFROG_CLI_TOOL_NAME_1, releasesInstaller, override);
}

public static void configureJfrogCliFromArtifactory(String toolName, String serverId, String repo, Boolean override) throws Exception {
Expand Down
Loading