Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Gotcha7770/Artifactory-Client-CSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Artifacotry-Client-CSharp Build status NuGet Version

Rest client for JFrog Artifactory service partially inspired by https://github.com/jfrog/artifactory-client-java

Now only search, downloading and uploading artifatcs is available.

There are three ways to create Artifactory client:

  1. with implementation of IRestClient
IRestClient client = new RestClient
{
    //url is dns name or ip address of your artifactory server
    //without any subfolders
    BaseUrl = new Uri("http:\\some\url"),
    Authenticator = new HttpBasicAuthenticator("userName", "password")
};

IArtifactory artifactory = ArtifactoryBuilder.CreateArtifactory()
    .SetRestClient(client)
    .Build();
  1. with implementation of IAuthenticator
IAuthenticator authenticator = new HttpBasicAuthenticator("userName", "password");

IArtifactory artifactory = ArtifactoryBuilder.CreateArtifactory()
    .SetAuthentificator(authenticator)
    .SetUrl("http:\\some\url")
    .Build();
  1. or just set properties
IArtifactory artifactory = ArtifactoryBuilder.CreateArtifactory()
    .SetUserName("userName")
    .SetPassword("password")
    .SetUrl("http:\\some\url")
    .Build();

Search

  1. Quick search
ArtifactslList artifactsList = _artifactory.Search()
    .Repositories("repositoryName", "anotherRepositoryName")
    .ByName("*.zip")
    .Run();
    
if(artifactsList.Response.StatusCode == HttpStatusCode.OK)
    return artifactsList.Artifacts;
  1. Properties search
ArtifactslList artifactsList = _artifactory.Search()
    .Repositories("repositoryName")
    .WithProperty("name", "someName")
    .WithProperty("version", "2.3.1")
    .WithOptions(ResponseOptions.Properties|ResponseOptions.Info)
    .Run();
  1. Create period search
ArtifactslList artifactsList = artifactory.Search()
    .Repositories("repositoryName")
    .ArtifactsCreatedInDateRange()
    .From(new DateTime(2018, 2, 24))
    .To(new DateTime(2018, 3, 24))
    .WithOptions(ResponseOptions.Properties)
    .Run();

Download artifacts

 IRestResponse response = artifactory.GetRepository("repositoryName").Download("your/artifact/path");

Upload artifacts

IRestResponse response = artifactory.GetRepository("repositoryName")
    .Upload("artifactName/artifactName.1.0.3.ext", bytes)
    .WithProperty("name", "artifactName")
    .WithProperty("version", "1.0.3")
    .WithProperty("dependencies", new[] { "dep1", "dep2" })
    .Run();

About

Rest client for Artifactory on C#

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages