Artifactory-Client

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# SYNOPSIS

This is a Perl client for Artifactory REST API:
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API Every public method provided in this module returns a
HTTP::Response object.

    use Artifactory::Client;

    my $h = HTTP::Headers->new();
    $h->authorization_basic( 'admin', 'password' );
    my $ua = LWP::UserAgent->new( default_headers => $h );

    my $args = {
        artifactory  => 'http://artifactory.server.com',
        port         => 8080,
        repository   => 'myrepository',
        context_root => '/', # Context root for artifactory. Defaults to 'artifactory'.
        ua           => $ua  # Dropping in custom UA with default_headers set.  Default is a plain LWP::UserAgent.
    };

    my $client = Artifactory::Client->new( $args );
    my $path = '/foo'; # path on artifactory

    # Properties are a hashref of key-arrayref pairs.  Note that value must be an arrayref even for a single element.
    # This is to conform with Artifactory which treats property values as a list.
    my $properties = {
        one => ['two'],
        baz => ['three'],
    };
    my $file = '/local/file.xml';

    # Name of methods are taken straight from Artifactory REST API documentation.  'Deploy Artifact' would map to
    # deploy_artifact method, like below.  The caller gets HTTP::Response object back.
    my $resp = $client->deploy_artifact( path => $path, properties => $properties, file => $file );

    # Custom requests can also be made via usual get / post / put / delete requests.
    my $resp = $client->get( 'http://artifactory.server.com/path/to/resource' );

    # Repository override for calls that have a repository in the endpoint.  The passed-in repository will not persist.
    my $resp = $client->calculate_yum_repository_metadata( repository => 'different_repo', async => 1 );

# Dev Env Setup / Running Tests

    carton install

    # to run unit tests
    prove -r t

# GENERIC METHODS

## get( @args )

Invokes GET request on LWP::UserAgent-like object; params are passed through.

## post( @args )

nvokes POST request on LWP::UserAgent-like object; params are passed through.

## put( @args )

Invokes PUT request on LWP::UserAgent-like object; params are passed through.

## delete( @args )

Invokes DELETE request on LWP::UserAgent-like object; params are passed
through.

## request( @args )

Invokes request() on LWP::UserAgent-like object; params are passed through.

# BUILDS

## all\_builds

Retrieves information on all builds from artifactory.

## build\_runs( $build\_name )

Retrieves information of a particular build from artifactory.

## build\_upload( $path\_to\_json )

Upload Build

## build\_info( $build\_name, $build\_number )

Retrieves information of a particular build number.

## builds\_diff( $build\_name, $new\_build\_number, $old\_build\_number )

Retrieves diff of 2 builds

## build\_promotion( $build\_name, $build\_number, $payload )

Promotes a build by POSTing payload

## promote\_docker\_image( targetRepo => "target\_repo", dockerRepository => "dockerRepository", tag => "tag", copy => 'false' )

Promotes a Docker image from one repository to another

## delete\_builds( name => $build\_name, buildnumbers => \[ buildnumbers \], artifacts => 0,1, deleteall => 0,1 )

Removes builds stored in Artifactory. Useful for cleaning up old build info data

## build\_rename( $build\_name, $new\_build\_name )

Renames a build

## distribute\_build( 'build\_name', $build\_number, %hash\_of\_json\_payload )

Deploys builds from Artifactory to Bintray, and creates an entry in the corresponding Artifactory distribution
repository specified.

## control\_build\_retention( 'build\_name', deleteBuildArtifacts => 'true', count => 100, ... )

Specifies retention parameters for build info.

# ARTIFACTS & STORAGE

## folder\_info( $path )



( run in 0.803 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )