Skip to content

Commit

Permalink
Jenkins.instance is missing in remote SSH agent (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Mar 14, 2023
1 parent 33da4ee commit a8b1402
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/io/jenkins/plugins/jfrog/BinaryInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@ public String getId() {
/**
* Download and locate the JFrog CLI binary in the specific build home directory.
*
* @param toolLocation - location of the tool directory on the fileSystem.
* @param log - job task listener.
* @param providedVersion - version provided by the user. empty string indicates the latest version.
* @param instance - JFrogPlatformInstance contains url and credentials needed for the downloading operation.
* @param repository - identifies the repository in Artifactory where the CLIs binary is stored.
* @param binaryName - 'jf' or 'jf.exe'
* @param toolLocation - Location of the tool directory on the fileSystem
* @param log - Job task listener
* @param providedVersion - Version provided by the user. empty string indicates the latest version
* @param instance - JFrogPlatformInstance contains url and credentials needed for the downloading operation
* @param repository - Identifies the repository in Artifactory where the CLIs binary is stored
* @param binaryName - 'jf' or 'jf.exe'
* @param proxyConfiguration - The proxy configuration or null if not configured
* @throws IOException in case of any I/O error.
*/
private static void downloadJfrogCli(File toolLocation, TaskListener log, String providedVersion, JFrogPlatformInstance instance, String repository, String binaryName) throws IOException {
private static void downloadJfrogCli(File toolLocation, TaskListener log, String providedVersion,
JFrogPlatformInstance instance, String repository, String binaryName, ProxyConfiguration proxyConfiguration) throws IOException {
// An empty string indicates the latest version.
String version = StringUtils.defaultIfBlank(providedVersion, RELEASE);
String cliUrlSuffix = String.format("/%s/v2-jf/%s/jfrog-cli-%s/%s", repository, version, OsUtils.getOsDetails(), binaryName);
Expand All @@ -92,7 +94,6 @@ private static void downloadJfrogCli(File toolLocation, TaskListener log, String
// Downloading binary from Artifactory
try (ArtifactoryManager manager = new ArtifactoryManager(instance.getArtifactoryUrl(), Secret.toString(instance.getCredentialsConfig().getUsername()),
Secret.toString(instance.getCredentialsConfig().getPassword()), Secret.toString(instance.getCredentialsConfig().getAccessToken()), buildInfoLog)) {
ProxyConfiguration proxyConfiguration = createProxyConfiguration();
if (proxyConfiguration != null) {
manager.setProxyConfiguration(proxyConfiguration);
}
Expand Down Expand Up @@ -159,11 +160,12 @@ private static String getArtifactSha256(ArtifactoryManager manager, String cliUr
}

public static FilePath performJfrogCliInstallation(FilePath toolLocation, TaskListener log, String version, JFrogPlatformInstance instance, String repository, String binaryName) throws IOException, InterruptedException {
ProxyConfiguration proxyConfiguration = createProxyConfiguration();
// Download Jfrog CLI binary
toolLocation.act(new MasterToSlaveFileCallable<Void>() {
@Override
public Void invoke(File f, VirtualChannel channel) throws IOException {
downloadJfrogCli(f, log, version, instance, repository, binaryName);
downloadJfrogCli(f, log, version, instance, repository, binaryName, proxyConfiguration);
return null;
}
});
Expand Down

0 comments on commit a8b1402

Please sign in to comment.