gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

Getting authentication error while downloading node distribution from company artficatory

Open kkatleri opened this issue 5 years ago • 3 comments

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.

kkatleri avatar Feb 08 '20 22:02 kkatleri

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
}

deepy avatar Feb 10 '20 07:02 deepy

I should've added this to the documentation earlier but I forgot

deepy avatar Feb 10 '20 07:02 deepy

Thank you @deepy for your response. I am now able to get to artifactory node distribution with your solution. Thanks a lot!

kkatleri avatar Feb 10 '20 21:02 kkatleri