gradle-node-plugin
gradle-node-plugin copied to clipboard
Getting authentication error while downloading node distribution from company artficatory
I tried using below two node plugins in my gradle build -
`id "com.moowork.node" version "1.3.1" `
and
` id "com.github.node-gradle.node" version "2.2.1" `
and this is how my gradle file looks like -
```
buildscript {
repositories {
maven{
url "http://artifactory.xxx.xxxxx/artifactory/plugins-release"
credentials {
username = "${artifact_user}"
password = "${artifact_password}"
}
}
}
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:0.12"
}
}
apply plugin: "java"
apply plugin: "com.moowork.node"
node {
version = '12.13.0'
npmVersion = '6.12.0'
distBaseUrl = 'http://username:password**@artifactory.xxx.xxxx/artifactory/node-repo/'
download = true
}
but when I run nodeSetup task using gradle nodeSetup command, getting below error -
> Could not resolve org.nodejs:node:12.13.0.
> Could not get resource 'http://artifactory.xxxx.xxxxxxx/artifactory/node-repo/v12.13.0/node-v12.13.0-win-x64.zip'.
> Could not HEAD 'http://artifactory..xxxx.xxxxxxx/artifactory/node-repo/v12.13.0/node-v12.13.0-win-x64.zip'. Received status code 401 from server: Unauthorized
I have verified the username and password. The same artifactory url with username]/password embedded in it works fine in the browser or postman, but getting authentication error in gradle build. Please advice.
In this case you want to use distBaseUrl = null and manually add an ivy repo with authentication
Something like
repositories.ivy {
setUrl('https://foo')
credentials {
username "me"
password "hunter2"
}
patternLayout {
artifact("[artifact](-v[revision]-[classifier]).[ext]")
}
metadataSources {
artifact()
}
}
node {
distBaseUrl = null
}
I should've added this to the documentation earlier but I forgot
Thank you @deepy for your response. I am now able to get to artifactory node distribution with your solution. Thanks a lot!