I've been migrating to a few artifactory which requires credentials. For all of my modules which require it, i've added the credentials into the build.gradle files like so:
repositories {
maven {
url 'https://myhost.jfrog.io/artifactory/proj'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
Upon each 401 error throughout the build, adding the above into its respective build.gradle file has worked just fine. But for some reason, when getting to the node setup in one of my project, lets call it "foo", im getting a 401 when trying to access the node package. Upon checking artifactory, this is an Ivy package.
I've created an identity token for this package in JFrog just like I have for the others, yet i still receive the same error when building. I've tried to use all the tokens I've created as well as hardcoding the user and password into the build.gradle to ensure the correct values are passed.. yet I cannot get passed this 401 error.. Am i doing something wrong when I comes to an Ivy repo? All the others were maven.
Current setup in the foo build.gradle:
apply from: '../gradle/sharedProperties.gradle'
repositories {
ivy {
url 'https://myhost.jfrog.io/artifactory/ivy'
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
}
// Tells the node plugin & tasks to get dependencies from artifactory
node { distBaseUrl = 'https://myhost.jfrog.io/artifactory/ivy' }
tasks.withType(NodeTask) { args += ['--registry', 'https://myhost.jfrog.io/artifactory/api/npm/npm/'] }
tasks.withType(NpmTask) { args += ['--registry', 'https://myhost.jfrog.io/artifactory/api/npm/npm/'] }
Error is:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':foo:nodeSetup'.
> Could not resolve all files for configuration ':foo:detachedConfiguration1'.
> Could not resolve org.nodejs:node:14.17.6.
Required by:
project :foo
> Could not resolve org.nodejs:node:14.17.6.
> Could not get resource 'https://myhost.jfrog.io/artifactory/ivy/v14.17.6/node-v14.17.6-win-x64.zip'.
> Could not HEAD 'https://myhost.jfrog.io/artifactory/ivy/v14.17.6/node-v14.17.6-win-x64.zip'. Received status code 401 from server:
It seems Ivy repositories must be passed credentials in a different way. I added this to build.gradle file and it was successful.
project.repositories.whenObjectAdded {
if (it instanceof IvyArtifactRepository) {
it.authentication {
basic(BasicAuthentication)
}
it.credentials {
username "user"
password "pass"
}
}
}