grunt-artifactory-artifact

2.0.0-rc.0 • Public • Published

grunt-artifactory-artifact

Forked from grunt-nexus-artifact https://github.com/RallySoftware/grunt-nexus-artifact Slightly enhanced error handling, added authentication and defaults to artifactory context paths

Download artifacts from JFrog Artifactory artifact repository. Publish artifacts to a JFrog Artifactory artifact repository. Only works with Mac and Linux

Why?

If you're using grunt for frontend development and Java for the backend, it is convenient to consolidate dependencies into one repository.

Getting Started

This plugin requires Grunt ~1.0.0. For Grunt ~0.4.0, use "grunt-artifactory-artifact" version "0.8.0"

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-artifactory-artifact --save-dev

or add the following to your package.json file:

{
  "devDependencies": {
    "grunt-artifactory-artifact": "1.0.0"
  }
}

Once the plugin has been installed, enabled it inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-artifactory-artifact');

Artifactory Fetch Task

Run this task with the grunt artifactory:target:fetch command.

Examples

artifactory: {
  client: {
    url: 'http://artifactory.google.com:8080',
    repository: 'jslibraries',
    options: {
      fetch: [
        { id: 'com.google.js:jquery:tgz:1.8.0', path: 'public/lib/jquery' }
      ]
    }
  }
}

In grunt, options cascade. If all of your artifacts come from the same artifactory server, you can do the following:

artifactory: {
  options: {
    url: 'http://artifactory.google.com:8080'
  },
  client: {
    options: {
      repository: 'jslibraries',
      fetch: [
        { id: 'com.google.js:jquery:tgz:1.8.0', path: 'public/lib/jquery' }
      ]
    }
  },
  build: {
    options: {
      repository: 'jstools',
      fetch: [
        { id: 'com.google.js:closure:tgz:0.1.0', path: 'tools/closure' }
      ]
    }
  }
}

Options

There are a number of options available.

url

Type: String

This defines the url of your artifactory repository. This should be the base URL plus port. Ex: http://your-artifactory-repository:8080

repository

Type: String

This defines the name of the repository. Since this task uses the REST API, the repository is not inferred

fetch

Type: Array{Object}

This defines an array of artifactory artifacts to be retrieved from artifactory. Each artifact has config options:

group_id

Type: String

This defines the group_id of the artifact. Ex: com.google.js

name

Type: String

This defines the name of the artifact. Ex: jquery

ext

Type: String

This defines the extension of the artifact. Ex: tgz

classifier

Type: String

This defines the optional classifier to the artifact name. Ex: javadoc

version

Type: String

This defines the version of the artifact. Ex: 1.8.0

id

Type: String

This is a shorthand for group_id, name, ext, version and optionally a classifier. This defines the id string of the artifact in the following format: {group_id}:{name}:{ext}:[{classifier}:]{version}

download_url

Type: String

If you have a custom URL scheme for your artifactory instance, you can specify a full-qualified URL for downloading an artifact. You still need to set the ext param for extraction purposes.

Ex:

com.google.js:jquery:tgz:1.8.0
path

Type: String

This defines the path where the artifact will be extracted to. Ex: public/lib/jquery

Artifactory package task

The package flag will run the publish config to package artifacts. It uses grunt-contrib-compress so the file configuration will be the same. Run this task with the grunt artifactory:target:package command.

Artifactory publish task

The publish flag will run the publish config to package and push artifacts up to artifactory. It uses grunt-contrib-compress so the file configuration will be the same. Run this task with the grunt artifactory:target:publish command.

Examples

artifactory: {
  options: {
    url: 'http://artifactory.google.com:8080',
    repository: 'jslibraries',
    username: 'admin',
    password: 'admin123'
  },
  client: {
    files: [
      { src: ['builds/**/*'] }
    ],
    options: {
      publish: [{
          archive: 'my-custom-archive-name.tgz',
          id: 'com.mycompany.js:built-artifact:tgz',
          version: 'my-version', 
          path: 'dist/'
      }],
      parameters: [
        'build.name=built-artifact',
        'version=my-version',
        'vcs.revision=my-revision',
      ]
    }
  }
}

In this example the id config is used, but the version is dropped. It can be specified in the id config or specified in the version config. This makes it easier to set the version dynamically.

Options

The options listed here are new or repurposed for publish

archive

Type String

This defines a custom name for the artifact archive.

path

Type String

This defines the temporary path for the compressed artifact.

files

Type Array

parameters

Type 'Array'

This takes a list of parameters which will be listed in the file properties in Artifactory.

decompress

Type 'Boolean'

When 'true', the artifact will attempt to be decompressed. Defaults to 'true'. Currently supports extensions 'tgz','jar','zip', and 'war'.

This parameter comes from grunt-contrib-compress. You can read about it at github.com/gruntjs/grunt-contrib-compress. There are some differences from the config on grunt-contrib-compress. First of all, ext is used from the artifact, so it doesn't need to be specified. mode is currently not supported. It will auto-configure based on the extension.

Release History

  • 2013-08-08 v0.2.0 Added support for publishing artifacts

Original grunt-nexus-artifact contributed by Nicholas Boll of Rally Software Forked grunt-artifactory-artifact contributed by David R. Lee (http://www.twitter.com/david_r_lee)

Readme

Keywords

Package Sidebar

Install

npm i grunt-artifactory-artifact

Weekly Downloads

1,225

Version

2.0.0-rc.0

License

MIT

Unpacked Size

16.8 kB

Total Files

5

Last publish

Collaborators

  • davidrlee