Repository layout is final
创建一个远程存储库之后你不能查nge it's layout so we recommend that you define it beforehand.
Built-in Custom Layout: vcs-default
Artifactory'sbuilt-indefault layout for VCS repositories (vcs-default) can work with both GitHub and BitBucket.
Below is an example of aCustom Layoutnamedvcs-default:
You can configure the Custom Layout, or simply copy the below code snippet into the relevant section in theAdministrationmodule,underRepository Management|Layouts.
vcs-default [orgPath]/[module]/[refs ]/[baseRev]/[module]-[baseRev](-[fileItegRev])(-[classifier]).[ext] false .* [a-zA-Z0-9]{40}
If a repository package layout is in a corresponding folder hierarchy, the Artifactory Version Cleanup tool correctly detects previously installed versions.
Searching for artifact versions using the REST API also works properly:
$ curl "http://localhost:8081/artifactory/api/search/versions?g=jquery&a=jquery&repos=github-cache" { "results" : [ { "version" : "2.0.3", "integration" : false }, { "version" : "master-062b5267d0a3538f1f6dee3df16da536b73061ea", "integration" : true } ] }
Remote Repositories
You need to create aRemote Repository作为一个缓存代理github.com. If necessary, you can do the same forbitbucket.orgor any otherremote git repository that you need.
Artifacts (such astar.gz
files) requested from a remote repository are cached on demand. You can remove downloaded artifacts from the remote repository cache, however, you can not manually deploy artifacts to a remote repository.
To create a remote repository to proxygithub.com
or an on-prem GitHub Enterprise repository, follow the steps below:
- In theAdministrationmodule, underRepositories| Repositories | Remote,clickNew Remote Repositoryand setVCSto be thePackage Type.
- Set theRepository Key, and specify theURLto be
https://github.com
(or your GitHub Enterprise URL endpoint) as displayed below: - Under VCS Settings, select the GitHub provider in theGit Providerfield and clickSave & Finish.
Git Providers
Artifactory supports proxying the following Git providers out-of-the-box: GitHub, Bitbucket, Stash, a remote Artifactory instance or a custom Git repository as displayed below:
Use the custom provider if you have a Git repository which does not exist in the pre-defined list. In this case, you need to provide Artifactory with the download paths for your Git tarballs.
You do so by providing 4 placeholders:
Placeholder | Description |
---|---|
{0} | Identifies the username or organization name. |
{1} | Identifies the repository name. |
{2} | Identifies the branch or tag name. |
{3} | Identifies the file extension to download. |
For example, GitHub exposes tarball downloads at:https://github.com/
Therefore, the custom download path configured for Artifactory should be{0}/{1}/archive/{2}.{3}
Using Stash or Bitbucket
If you are using Stash or BitBucket, you need to download and install theBitBucket Server Archive Plugin.
Once the JAR is downloaded, select it in your Stash UI, underAdministration | Manage add-ons | Upload add-on.
Once you have installed the add-on you need to restart Stash.
Using the API
VCS repositories must be prefixed with api/vcs in the path
When accessing a VCS repository through Artifactory, the repository URL must be prefixed withapi/vcsin the path.
For example, if you are using Artifactory standalone or as a local service, you would access your VCS repositories using the following URL:
http://localhost:8081/artifactory/api/vcs/
Or, if you are using Artifactory Cloud, the URL would be:
https://
Artifactory exposes REST APIs that let you do the following with VCS repositories:
- List all tags
- List all branches
- Download a specific tag
- Download a file within a tag
- Download a specific branch
- Download a file within a branch
- Download a release
To help you build the API call correctly, you can select the VCS repository you want to interact with and clickSet Me Up.
Examples
Below are some examples of working with the API using cURL:
curl -i "http://localhost:8080/artifactory/api/vcs/downloadBranch/github/jquery/jquery/master"
curl -i "http://localhost:8080/artifactory/api/vcs/downloadTag/bitbucket/lsystems/angular-extended-notifications/1.0.0"
curl -i "http://localhost:8080/artifactory/api/vcs/downloadTagFile/github/jquery/jquery/2.0.1%21AUTHORS.txt"
When files are already cached, you can conditionally request them using a properties query param:
curl -i "http://localhost:8080/artifactory/api/vcs/downloadBranch/github/jquery/jquery/2.0.1?properties=qa=approved"
Accessing Private VCS Repositories
Artifactory also supports accessing private VCS repositories such as a private GitHub or any self-hosted authenticated one.
To do so, simply add your credentials underAdvanced Settingsof the remote repository configuration panel.
Credentials when redirected
Some git providers (GitHub included) redirects download requests to a CDN provider.
You will need your credentials to pass along with the redirected request, simply check theLenient Host Authenticationand the credentials will pass transparently on each redirected request.