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:
- 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();
- with implementation of IAuthenticator
IAuthenticator authenticator = new HttpBasicAuthenticator("userName", "password");
IArtifactory artifactory = ArtifactoryBuilder.CreateArtifactory()
.SetAuthentificator(authenticator)
.SetUrl("http:\\some\url")
.Build();
- or just set properties
IArtifactory artifactory = ArtifactoryBuilder.CreateArtifactory()
.SetUserName("userName")
.SetPassword("password")
.SetUrl("http:\\some\url")
.Build();
- Quick search
ArtifactslList artifactsList = _artifactory.Search()
.Repositories("repositoryName", "anotherRepositoryName")
.ByName("*.zip")
.Run();
if(artifactsList.Response.StatusCode == HttpStatusCode.OK)
return artifactsList.Artifacts;
- Properties search
ArtifactslList artifactsList = _artifactory.Search()
.Repositories("repositoryName")
.WithProperty("name", "someName")
.WithProperty("version", "2.3.1")
.WithOptions(ResponseOptions.Properties|ResponseOptions.Info)
.Run();
- 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();
IRestResponse response = artifactory.GetRepository("repositoryName").Download("your/artifact/path");
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();