artifactory-publisher
A simple tool for publishing files to Artifactory
artifactory-publisher
is a simple tool for publishing files to Artifactory via its REST API.
Also please check this other (more superior) tool - artifactory-client (WIP).
API
publish(filePath, artUrl, options)
Publish filePath
file (artifact) to artUrl
url with using options
.
Returns a Q
promise to be resolved when the artifact has published.
filePath
Type: String
Required: yes
A path to a file to publish (in terms of fs
Node module).
artUrl
Type: String
Required: yes
Fully qualified url of artifact.
For example 'http://artifacts.mydomain.com:8001/my-repo/MyProduct/1.1/Subsystem1/MyProduct.Subsystem1.1.0.0.nupkg'.
Here:
- "http://artifacts.mydomain.com:8001/" - base Artifactory url (it usually contains /artifactory path)
- "my-repo" - repository name
- "MyProduct/1.1/Subsystem1/" - path in repository
- "MyProduct.Subsystem1.1.0.0.nupkg" - file name (package)
options
Type: Object
Required: no
Options object.
options.credentials
Type: Object
Required: no
An object with fields:
- username - Artifactory user name
- password - Artifactory user password
options.proxy
Type: String
Required: no
A proxy url to use for sending http requests.
Examples
via Node
Here's a simple app (to run under Node) which publishes nuget packages into custom folders depending on their file names (it's hard to implement via Repository Layout in Artifactory).
var fs = ;var path = ;var Q = ;var async = ;var publisher = ; var artUrlBase = "http://artifacts.mydomain.com/my-repo/"; var options = credentials: username: "user1" password: "password2" //proxy: "http://localhost:8888" - to debug with Fiddler var args = splice;var folderPath;if argslength === 0 console; return; else folderPath = args0; { // XFW3.Core.1.16.0.nupkg => {product: "XFW3", version: "1.16"} // XFW3.SmartClient.1.15.2.nupkg => {product: "XFW3.SmartClient", version: "1.15"} // XFW3.WebClient.0.19.0.nupkg => {product: "XFW3.WebClient", version: "0.19"} if !fs return; var filename = pathname; if !filename return; var parts = /\.\.[\d]+.*\.nupkg/ if !parts return; return product: parts1 version: parts2 ;} fs;
via command line
The tool can be run via CLI as well:
artifactory-publisher -f "path/to/local/file.ext" -t http://artifacts.mydomain.com/my-repo/file.ext -u user1 -p password2
Acknowledgments
Code for CLI tool artifactory-publisher
was barrowed from package artifactory-push by @beevelop.
Licence
MIT