Skip to content

Commit

Permalink
Make the resolution repository preemptive (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Aug 20, 2024
1 parent 01b82cb commit 171ce9a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.gradle.api.GradleException;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.invocation.Gradle;
import org.gradle.authentication.http.BasicAuthentication;
import org.jfrog.build.api.builder.ModuleType;
import org.jfrog.build.api.util.Log;
import org.jfrog.build.client.Version;
Expand Down Expand Up @@ -67,6 +68,12 @@ public static void addArtifactoryResolutionRepositoryAction(MavenArtifactReposit
credentials.setUsername(username);
credentials.setPassword(password);
});

// Before resolving an artifact from Artifactory, Gradle typically sends a preemptive challenge request and
// expects a 401 response from the server.
// However, when 'Hide Existence of Unauthorized Resources' is enabled, Artifactory returns a 404 instead.
// Adding BasicAuthentication ensures that credentials are sent directly, bypassing this challenge.
mavenArtifactRepository.authentication(authentications -> authentications.create("basic", BasicAuthentication.class));
}
}

Expand Down

0 comments on commit 171ce9a

Please sign in to comment.