Uploading Artifacts using shell commands


#1

How can I upload artifacts to nexus using linux command line? I am working on node.js, npm project? dist folder have been created using npm install and npm run build commands. But now I don’t know how to upload artifacts? Can someone explain this to me because I am new to these things.

I used this command,

curl --upload-file dist.tgz -v -u admin:zone@123 http://192.168.94.136:8081/repository/frontend_snap/hosted/zissa/dist.tgz

But I am getting error.

  • About to connect() to 192.168.94.136 port 8081 (#0)
  • Trying 192.168.94.136…
  • Connected to 192.168.94.136 (192.168.94.136) port 8081 (#0)
  • Server auth using Basic with user ‘admin’

PUT /repository/frontend_snap/hosted/zissa/dist.tgz HTTP/1.1
Authorization: Basic YWRtaW46em9uZUAxMjM=
User-Agent: curl/7.29.0
Host: 192.168.94.136:8081
Accept: /
Content-Length: 13786906
Expect: 100-continue

< HTTP/1.1 400 Bad Request
< Date: Wed, 31 Oct 2018 13:31:10 GMT
< Server: Nexus/3.14.0-04 (OSS)
< X-Content-Type-Options: nosniff
< Content-Security-Policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< Connection: close

I have created npm(hosted) repository called frontend_snap


#2

We have some documentation around publishing npm packages to hosted repos that might be helpful, check it out here:

https://help.sonatype.com/repomanager3/node-packaged-modules-and-npm-registries#NodePackagedModulesandnpmRegistries-PublishingnpmPackages


#3

But I want to upload dist.tgz without using npm publish command. Can’t we use mvn deploy plugin?


#4

You can also use the REST API: https://help.sonatype.com/display/NXRM3/Components+API#ComponentsAPI-NPM


#5

@janithh92 given that you are just getting started with this, I would strongly encourage you to take a second look at npm publish and how to set up .npmrc. Your project and repository are all npm, so why not use the built in npm tooling to package and distribute your application?

While it may be possible to upload and download from a repository in a variety of different ways, creating custom processes that are outside of the native tooling is, in my opinion, one of those “code smells” that will lead to confusion and bugs down the road and should be avoided.