I've configured gradle build to use our company's nexus repo but maven does not seem to be able to authorized correctly - I keep getting erros such as
Failed to get resource: HEAD. [HTTP HTTP/1.1 401 Authorization Required: https://maven.gooddata.com/nexus/content/repositories/gooddata/org/codehaus/groovy/groovy-all/2.0.4/groovy-all-2.0.4.pom]
Strangely enough, the deploying to the same nexus repo (via mavenDeployer) is working seamlessly.
Below is part of my build script related to the maven repo configuration (maven_user and maven_password are defined in ~/.gradle/gradle.properties).
apply plugin: 'maven'
ext {
repos = [
my : "<my_repo_url>",
my_snapshot : "<my_snapshots_repo_url>"
]
}
repositories {
mavenLocal()
maven {
url repos.my
credentials {
username = maven_user
password = maven_password
}
}
maven {
url repos.my_snapshot
credentials {
userName = maven_user
password = maven_password
}
}
mavenCentral()
maven { url "http://repository.codehaus.org/" }
maven { url "http://sardine.googlecode.com/svn/maven" }
maven { url "http://snapshots.repository.codehaus.org" }
}
uploadArchives {
repositories.mavenDeployer {
repository(url : repos.my) {
authentication(userName : maven_user, password : maven_password)
}
snapshotRepository(url : repos.my_snapshot) {
authentication(userName : maven_user, password : maven_password)
}
}
}
Any suggestions what's going on?
The 401 Unauthorized Error is an HTTP status code error that represented the request sent by the client to the server that lacks valid authentication credentials. It may be represented as 401 Unauthorized, Authorization required, HTTP error 401- Unauthorized. It represents that the request could not be authenticated.
Nexus Repository OSS is an open source repository that supports many artifact formats, including Docker, Java™, and npm. With the Nexus tool integration, pipelines in your toolchain can publish and retrieve versioned apps and their dependencies by using central repositories that are accessible from other environments.
Your username property is capitalized wrongly and you should leave out the '=' sign with the username and password setting. Changing your repository definition to the following should solve your problems:
maven {
url repos.my
credentials {
username maven_user
password maven_password
}
}
Thread is a bit old now, but just wanted to highlight a gotcha I had when following the above .. my admin had created a password with both a single and double quote in, which resulted in a similar 401
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With