Curtis Olson
Curtis Olson

Reputation: 49

Artifactory Gradle plugin - invalid target host resolution URL

I'm having an issue with resolving the location of my artifactory repository, in that the host name is getting mangled. Particulary, despite the context URL or repository key, the target host section is getting translated to "http:/artifactory". Note the single slash - I'm not configuring this *anywhere".

Here's the snippet from build.gradle:

artifactory {
contextUrl = 'http://myserver:8081/artifactory'  //The base Artifactory URL if not overridden by the publisher/resolver
publish {
    repository {
        repoKey = 'libs-snapshot-local'
      maven = true
        username = 'user'
        password = 'password'
    }
   defaults {
        publications ('mavenJava')
    }
}
resolve {
    repository {
        repoKey = 'libs-release'
        maven = true
        username = 'user'
        password = 'password'
    }
  }
}

The error I see is:

> Could not get resource 'http:/artifactory/libs-release/org/springframework/boot/spring-boot-starter-parent/1.3.0.RELEASE/spring-boot-starter-parent-1.3.0.RELEASE.pom'.
     > Target host must not be null, or set in parameters.

You'll see above the single slash after "http:" and a domain name of "artifactory". Weird.

I've also attempted to specify the Context URL again in each of the publish and resolve blocks, same results. Neither settings.gradle nor build.properties has anything in it that might override the context URL. After several hours, I'm stumped. Advice?

Upvotes: 0

Views: 310

Answers (2)

John Cummings
John Cummings

Reputation: 16

This can happen if your host is invalid, for instance, if it contains an underscore. I was able to get this exact issue by putting an underscore in the host, and the issue went away when I took it out. Looks like a similar issue here:

https://stackoverflow.com/questions/29775942/maven-repositories-with-underscores-in-the-url-gives-notransportexception-in-a

The host is considered invalid and isn't used to connect. Perhaps the extra slashes bypass that by making the myserver:8081 escape validation by resembling part of the path rather than the host.

Upvotes: 0

Curtis Olson
Curtis Olson

Reputation: 49

I ended up doubling the slashes prepending the domain in the context URL, as follows:

contextUrl = 'http:////myserver:8081/artifactory'

It would then build the resolver URL correctly, as:

http://myserver:8081/artifactory/libs-release

Dunno.

Upvotes: 1

Related Questions