Open tkrah opened 3 years ago
Some debugging revealed some interesting things - the actual request made is e.g.:
https://tkrah:MY_CREDENTIALS@artifacts.localhost.local/api/v1/versions/colorize.json
This won't work - the repository does not run under that URL - it's missing the whole part about the gem-repos url part:
/artifactory/api/gems/gems-repos/
Additionally the OkHttpBuilder has a auth part called
applyAuth(requestBuilder, chainedConfig);
which has this:
private static void applyAuth(final Request.Builder requestBuilder, final ChainedHttpConfig chainedConfig) {
final HttpConfig.Auth auth = chainedConfig.getChainedRequest().actualAuth();
if (auth != null) {
switch (auth.getAuthType()) {
case BASIC:
requestBuilder.addHeader("Authorization", Credentials.basic(auth.getUser(), auth.getPassword()));
break;
case DIGEST:
// supported in constructor with an interceptor
}
}
}
but authentication was not configured for that request (although it's included in the configured URL) - not sure if it will be respected or not, can't tell for sure because the whole URL does not match the configured one.
Maybe someone has an idea what's wrong.
I have this problem as well. I'm using this plugin to run a Ruby script (with gems) as part of my gradle build. Everything works fine if I use the default ruby.gems()
repository, but I can't find a way to tell it to use my artifactory instance instead.
Using bundler, I changed my Gemfile from source "https://rubygems.org"
to source "https://myartifactory.jfrog.io/artifactory/api/gems/gems/"
and stored my credentials in an environment variable
export BUNDLE_MYARTIFACTORY__JFROG__IO="user:pwd"
and that works great for bundler. I tried doing the obvious thing similar to @tkrah and changing the repo to ruby.gems("https://user:pwd@myartifactory.jfrog.io/artifactory/api/gems/gems")
but that fails to resolve with a similar error
404 client error for request to /rubygems/twine/1.1.1/ivy.xml
> Task :myproj:jrubyPrepare FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myproj:jrubyPrepare'.
> Could not resolve all dependencies for configuration ':myproj:gems'.
> Could not find rubygems:twine:1.1.1.
Searched in the following locations:
- http://localhost:61344/rubygems/twine/1.1.1/ivy.xml
- https://myartifactory.jfrog.io/artifactory/libs-release/rubygems/twine/1.1.1/twine-1.1.1.pom
Required by:
project :myproj
I think the fact that it searched http://localhost:61344/rubygems/twine/1.1.1/ivy.xml
is promising, because that's the internal ivy proxy that the jruby plugin sets up. The annoying part is I can't find any way to see how that proxy is trying to resolve my custom URI. So it's hard to debug.
@silverhammermba look at https://github.com/jruby-gradle/jruby-gradle-plugin/issues/429#issuecomment-937835472 - I've debugged through the code - the whole url resolution is wrong if you specify a custom repository and auth is unconfigured.
As far as I can tell, this fails because the authentication is never configured here:
I believe fixing this would require either parsing the credentials out of the URI, or providing them from an external file or environment variable (I would probably allow for all 3 options) in the two DefaultRubyGemRestApi constructors, and creating a new function signature like this:
private static HttpBuilder getHttpBuilder(URI uri, String username, String password) {
configure {
request.uri = uri
request.auth.basic username, password
client.clientCustomizer { OkHttpClient.Builder builder ->
builder.followRedirects(true)
builder.followSslRedirects(true)
}
}
}
The constructors would call this signature is authentication was provided. There's probably a cleaner way to fix this, but that's the first way I could think of.
Hi,
I tried to get a custom gem repository working with jRuby but it does not work like described.
I did configure my local .gemrc with that URL which it should use (custom mirror - artifactory) and it works just fine with "gem install ..." etc. - so the upstream mirror is ok.
I choose to modify the example from the project:
https://github.com/jruby-gradle/jruby-gradle-plugin/tree/master/examples/run-script-with-jruby-args
and modified the repository line from
ruby.gems()
to
ruby.gems("https://tkrah:MY_CREDENTIALS@artifacts.localhost.local/artifactory/api/gems/gems-repos/")
Running the gradle task runGradleTest now just results in this output instead of a successful build:
So how do you use a custom repository with jRuby gradle plugin here? Just using the same URL which does work for command line running gem is not going to work here.